shared/shell: Omit menu command if there are no submenus
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/4 shared/shell: Omit menu command if there are no submenus
From: Luiz Augusto von Dentz <[email protected]>
There is no need to show menu as a command if there are no submenus to select.
--- src/shared/shell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
src/shared/shell.c +5 -2
@@ -195,8 +195,11 @@ static void shell_print_menu(void) }for (entry = default_menu; entry->cmd; entry++) { -/* Skip menu command if not on main menu */ -if (data.menu != data.main && !strcmp (entry->cmd,"menu" )) +/* Skip menu command if not on main menu or if there are no +* submenus. +*/ +if ((data.menu != data.main && !strcmp (entry->cmd,"menu" )) || +queue_isempty (data.submenus))continue ;/* Skip back command if on main menu */
Signature · 1 line
2.13.6
Luiz Augusto von Dentz
maintainerPATCH 2/4 mesh: Make meshctl use bt_shell helpers
From: Luiz Augusto von Dentz <[email protected]>
This makes meshctl use bt_shell to manage the menus and command handling.
--- Makefile.tools | 1 - mesh/agent.c | 22 +- mesh/config-client.c | 187 +++++++--------- mesh/config-model.h | 1 - mesh/config-server.c | 17 +- mesh/gatt.c | 36 ++-- mesh/main.c | 592 ++++++++++++++------------------------------------- mesh/net.c | 16 +- mesh/node.c | 10 +- mesh/onoff-model.c | 88 +++----- mesh/prov-db.c | 25 ++- mesh/prov.c | 16 +- mesh/util.c | 179 ++-------------- mesh/util.h | 16 +- 14 files changed, 354 insertions(+), 852 deletions(-)
Makefile.tools +0 -1
@@ -30,7 +30,6 @@ mesh_meshctl_SOURCES = mesh/main.c \ mesh/config-model.h mesh/config-client.c \ mesh/config-server.c \ mesh/onoff-model.h mesh/onoff-model.c \ - client/display.h client/display.c \ monitor/uuid.h monitor/uuid.c mesh_meshctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ lib/libbluetooth-internal.la \
mesh/agent.c +11 -11
@@ -29,12 +29,12 @@#include <stdlib.h> #include <stdbool.h> #include <inttypes.h> -#include <readline/readline.h> #include <glib.h> #include <lib/bluetooth.h> -#include "client/display.h" + +#include "src/shared/shell.h" #include "mesh/util.h" #include "mesh/agent.h"
@@ -68,7 +68,7 @@ static void response_hexadecimal(const char *input, void *user_data)uint8_t buf[MAX_HEXADECIMAL_OOB_LEN ];if (!str2hex (input,strlen (input), buf, pending_request.len) ) { -rl_printf ("Incorrect input: expecting %d hex octets\n" , +bt_shell_printf ("Incorrect input: expecting %d hex octets\n" , pending_request.len);return ; }
@@ -110,8 +110,8 @@ static bool request_hexadecimal(uint16_t len)if (len >MAX_HEXADECIMAL_OOB_LEN )return false; -rl_printf ("Request hexadecimal key (hex %d octets)\n" , len); -rl_prompt_input ("mesh" ,"Enter key (hex number):" , response_hexadecimal, +bt_shell_printf ("Request hexadecimal key (hex %d octets)\n" , len); +bt_shell_prompt_input ("mesh" ,"Enter key (hex number):" , response_hexadecimal,NULL );return true;
@@ -129,8 +129,8 @@ static uint32_t power_ten(uint8_t power)static bool request_decimal (uint16_t len) { -rl_printf ("Request decimal key (0 - %d)\n" ,power_ten (len) -1 ); -rl_prompt_input ("mesh" ,"Enter Numeric key:" , response_decimal,NULL ); +bt_shell_printf ("Request decimal key (0 - %d)\n" ,power_ten (len) -1 ); +bt_shell_prompt_input ("mesh" ,"Enter Numeric key:" , response_decimal,NULL );return true; }
@@ -140,8 +140,8 @@ static bool request_ascii(uint16_t len)if (len >MAX_ASCII_OOB_LEN )return false; -rl_printf ("Request ASCII key (max characters %d)\n" , len); -rl_prompt_input ("mesh" ,"Enter key (ascii string):" , response_ascii, +bt_shell_printf ("Request ASCII key (max characters %d)\n" , len); +bt_shell_prompt_input ("mesh" ,"Enter key (ascii string):" , response_ascii,NULL );return true;
@@ -194,7 +194,7 @@ bool agent_output_request(const char* str)return false; pending_request.type =OUTPUT ; -rl_prompt_input ("mesh" , str, response_output,NULL ); +bt_shell_prompt_input ("mesh" , str, response_output,NULL );return true; }
@@ -203,5 +203,5 @@ void agent_output_request_cancel(void)if (pending_request.type !=OUTPUT )return ; pending_request.type =NONE ; -rl_release_prompt ("" ); +bt_shell_release_prompt ("" ); }
mesh/config-client.c +81 -106
497 lines not on this page · raw message
mesh/config-model.h +0 -1
@@ -99,4 +99,3 @@bool config_server_init (void );bool config_client_init (void );void config_client_get_composition (uint32_t dst); -void config_set_node (const char *args);
mesh/config-server.c +8 -9
@@ -34,12 +34,11 @@#include <stdbool.h> #include <sys/uio.h> #include <wordexp.h> -#include <readline/readline.h> -#include <readline/history.h> +#include <glib.h> #include "src/shared/util.h" -#include "client/display.h" +#include "src/shared/shell.h" #include "mesh/mesh-net.h" #include "mesh/keys.h" #include "mesh/net.h"
@@ -99,7 +98,7 @@ static bool server_msg_recvd(uint16_t src, uint8_t *data,if (len !=11 && len !=13 )return true; -rl_printf ("Set publication\n" ); +bt_shell_printf ("Set publication\n" ); ele_addr =get_le16 (data); mod_id =get_le16 (data +9 );
@@ -115,22 +114,22 @@ static bool server_msg_recvd(uint16_t src, uint8_t *data, m = (data[7 ] &0x3f );switch (data[7 ] >>6 ) {case 0 : -rl_printf ("Period: %d ms\n" , m *100 ); +bt_shell_printf ("Period: %d ms\n" , m *100 );break ;case 2 : m *=10 ;/* fall through */ case 1 : -rl_printf ("Period: %d sec\n" , m); +bt_shell_printf ("Period: %d sec\n" , m);break ;case 3 : -rl_printf ("Period: %d min\n" , m *10 ); +bt_shell_printf ("Period: %d min\n" , m *10 );break ; } pub.retransmit = data[8 ]; -rl_printf ("Retransmit count: %d\n" , data[8 ] >>5 ); -rl_printf ("Retransmit Interval Steps: %d\n" , data[8 ] &0x1f ); +bt_shell_printf ("Retransmit count: %d\n" , data[8 ] >>5 ); +bt_shell_printf ("Retransmit Interval Steps: %d\n" , data[8 ] &0x1f ); ele_idx = ele_addr -node_get_primary (node);
mesh/gatt.c +17 -19
@@ -33,15 +33,13 @@#include <sys/uio.h> #include <wordexp.h> -#include <readline/readline.h> -#include <readline/history.h> #include <glib.h> #include "src/shared/io.h" +#include "src/shared/shell.h" #include "gdbus/gdbus.h" #include "lib/bluetooth.h" #include "lib/uuid.h" -#include "client/display.h" #include "mesh/node.h" #include "mesh/util.h" #include "mesh/gatt.h"
@@ -216,7 +214,7 @@ static bool pipe_write(struct io *io, void *user_data) err =io_send (io, iov,2 );if (err <0 ) { -rl_printf ("Failed to write: %s\n" ,strerror (-err)); +bt_shell_printf ("Failed to write: %s\n" ,strerror (-err));write_data_free (data);return false; }
@@ -259,7 +257,7 @@ static void write_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == TRUE) { -rl_printf ("Failed to write: %s\n" , error.name); +bt_shell_printf ("Failed to write: %s\n" , error.name);dbus_error_free (&error);return ; }
@@ -307,7 +305,7 @@ static void write_reply(DBusMessage *message, void *user_data)if (g_dbus_proxy_method_call (data->proxy,"WriteValue" , write_setup, write_reply, data, write_data_free) == FALSE) { -rl_printf ("Failed to write\n" ); +bt_shell_printf ("Failed to write\n" );write_data_free (data);return ; }
@@ -330,7 +328,7 @@ static void notify_io_destroy(void)static bool pipe_hup (struct io *io,void *user_data) { -rl_printf ("%s closed\n" , io == notify_io ?"Notify" :"Write" ); +bt_shell_printf ("%s closed\n" , io == notify_io ?"Notify" :"Write" );if (io == notify_io)notify_io_destroy ();
@@ -366,7 +364,7 @@ static void acquire_write_reply(DBusMessage *message, void *user_data)if (g_dbus_proxy_method_call (data->proxy,"WriteValue" , write_setup, write_reply, data, write_data_free) == FALSE) { -rl_printf ("Failed to write\n" ); +bt_shell_printf ("Failed to write\n" );write_data_free (data); }return ;
@@ -375,11 +373,11 @@ static void acquire_write_reply(DBusMessage *message, void *user_data)if ((dbus_message_get_args (message,NULL ,DBUS_TYPE_UNIX_FD , &fd,DBUS_TYPE_UINT16 , &write_mtu,DBUS_TYPE_INVALID ) == false)) { -rl_printf ("Invalid AcquireWrite response\n" ); +bt_shell_printf ("Invalid AcquireWrite response\n" );return ; } -rl_printf ("AcquireWrite success: fd %d MTU %u\n" , fd, write_mtu); +bt_shell_printf ("AcquireWrite success: fd %d MTU %u\n" , fd, write_mtu); write_io =pipe_io_new (fd);
@@ -441,7 +439,7 @@ bool mesh_gatt_write(GDBusProxy *proxy, uint8_t *buf, uint16_t len,if (g_dbus_proxy_method_call (proxy,"AcquireWrite" , acquire_setup, acquire_write_reply, data,NULL ) == FALSE) { -rl_printf ("Failed to AcquireWrite\n" ); +bt_shell_printf ("Failed to AcquireWrite\n" );write_data_free (data);return false; }
@@ -449,12 +447,12 @@ bool mesh_gatt_write(GDBusProxy *proxy, uint8_t *buf, uint16_t len,if (g_dbus_proxy_method_call (data->proxy,"WriteValue" , write_setup, write_reply, data, write_data_free) == FALSE) { -rl_printf ("Failed to write\n" ); +bt_shell_printf ("Failed to write\n" );write_data_free (data);return false; }print_byte_array ("GATT-TX: " , buf, len); -rl_printf ("Attempting to write %s\n" , +bt_shell_printf ("Attempting to write %s\n" ,g_dbus_proxy_get_path (proxy)); }
@@ -469,13 +467,13 @@ static void notify_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == TRUE) { -rl_printf ("Failed to %s notify: %s\n" , +bt_shell_printf ("Failed to %s notify: %s\n" , data->enable ?"start" :"stop" , error.name);dbus_error_free (&error); goto done; } -rl_printf ("Notify %s\n" , data->enable ?"started" :"stopped" ); +bt_shell_printf ("Notify %s\n" , data->enable ?"started" :"stopped" ); done:if (data->cb)
@@ -535,7 +533,7 @@ static void acquire_notify_reply(DBusMessage *message, void *user_data)dbus_error_free (&error);if (g_dbus_proxy_method_call (data->proxy,"StartNotify" ,NULL , notify_reply, data,NULL ) == FALSE) { -rl_printf ("Failed to StartNotify\n" ); +bt_shell_printf ("Failed to StartNotify\n" );g_free (data); }return ;
@@ -553,13 +551,13 @@ static void acquire_notify_reply(DBusMessage *message, void *user_data) DBUS_TYPE_INVALID) == false)) {if (g_dbus_proxy_method_call (data->proxy,"StartNotify" ,NULL , notify_reply, data,NULL ) == FALSE) { -rl_printf ("Failed to StartNotify\n" ); +bt_shell_printf ("Failed to StartNotify\n" );g_free (data); }return ; } -rl_printf ("AcquireNotify success: fd %d MTU %u\n" , fd, notify_mtu); +bt_shell_printf ("AcquireNotify success: fd %d MTU %u\n" , fd, notify_mtu);if (g_dbus_proxy_get_property (data->proxy,"UUID" , &iter) == FALSE) goto done;
@@ -619,7 +617,7 @@ bool mesh_gatt_notify(GDBusProxy *proxy, bool enable, GDBusReturnFunction cb,if (g_dbus_proxy_method_call (proxy, method, setup, cb, data,NULL ) == FALSE) { -rl_printf ("Failed to %s\n" , method); +bt_shell_printf ("Failed to %s\n" , method);return false; }return true;
mesh/main.c +158 -434
1,270 lines not on this page · raw message
mesh/net.c +8 -8
@@ -33,7 +33,7 @@#include <glib.h> #include "src/shared/util.h" -#include "client/display.h" +#include "src/shared/shell.h" #include "mesh/crypto.h" #include "mesh/gatt.h"
@@ -958,7 +958,7 @@ static void beacon_update(bool first, bool iv_update, uint32_t iv_index)/* Enforcement of 96 hour and 192 hour IVU time windows */ if (iv_update && !net.iv_update) { -rl_printf ("iv_upd_state = IV_UPD_UPDATING\n" ); +bt_shell_printf ("iv_upd_state = IV_UPD_UPDATING\n" ); net.iv_upd_state =IV_UPD_UPDATING ;/* TODO: Start timer to enforce IV Update parameters */ }else if (first) {
@@ -967,11 +967,11 @@ static void beacon_update(bool first, bool iv_update, uint32_t iv_index)else net.iv_upd_state =IV_UPD_NORMAL ; -rl_printf ("iv_upd_state = IV_UPD_%s\n" , +bt_shell_printf ("iv_upd_state = IV_UPD_%s\n" , iv_update ?"UPDATING" :"NORMAL" ); }else if (iv_update && iv_index != net.iv_index) { -rl_printf ("IV Update too soon -- Rejecting\n" ); +bt_shell_printf ("IV Update too soon -- Rejecting\n" );return ; }
@@ -1060,7 +1060,7 @@ static bool process_beacon(uint8_t *data, uint8_t size)if ((net.iv_index +IV_IDX_DIFF_RANGE < iv_index) || (iv_index < net.iv_index)) { -rl_printf ("iv index outside range\n" ); +bt_shell_printf ("iv index outside range\n" );return false; }
@@ -1076,7 +1076,7 @@ static bool process_beacon(uint8_t *data, uint8_t size)if (iv_update && (net.iv_upd_state >IV_UPD_UPDATING )) {if (iv_index != net.iv_index) { -rl_printf ("Update too soon -- Rejecting\n" ); +bt_shell_printf ("Update too soon -- Rejecting\n" ); }/* Silently ignore old beacons */ return true;
@@ -1198,7 +1198,7 @@ static void send_pkt_cmplt(DBusMessage *message, void *user_data)g_free (pkt); }else {/* This is a serious error, and probable memory leak */ -rl_printf ("ERR: send_pkt_cmplt %p not head of queue\n" , pkt); +bt_shell_printf ("ERR: send_pkt_cmplt %p not head of queue\n" , pkt); } l =g_list_first (net.pkt_out);
@@ -1381,7 +1381,7 @@ static bool proxy_ctl_rxed(uint16_t net_idx, uint32_t iv_index,return false; net.blacklist = !!(trans[1 ] ==BLACKLIST_FILTER ); -rl_printf ("Proxy %slist filter length: %d\n" , +bt_shell_printf ("Proxy %slist filter length: %d\n" , net.blacklist ?"Black" :"White" ,get_be16 (trans +2 ));
mesh/node.c +4 -6
@@ -34,12 +34,10 @@#include <wordexp.h> #include <inttypes.h> -#include <readline/readline.h> -#include <readline/history.h> #include <glib.h> -#include "client/display.h" #include "src/shared/util.h" +#include "src/shared/shell.h" #include "gdbus/gdbus.h" #include "monitor/uuid.h" #include "mesh/mesh-net.h"
@@ -450,7 +448,7 @@ bool node_parse_composition(struct mesh_node *node, uint8_t *data, uint16_t len)bool node_set_local_node (struct mesh_node *node) {if (local_node) { -rl_printf ("Local node already registered\n" ); +bt_shell_printf ("Local node already registered\n" );return false; }net_register_unicast (node->primary, node->num_ele);
@@ -516,7 +514,7 @@ void node_local_data_handler(uint16_t src, uint32_t dst,if (!remote) {if (local_node->provisioner) { -rl_printf ("Remote node unknown (%4.4x)\n" , src); +bt_shell_printf ("Remote node unknown (%4.4x)\n" , src);return ; }
@@ -538,7 +536,7 @@ void node_local_data_handler(uint16_t src, uint32_t dst, iv_seq |= remote->seq_number;if (iv_seq_remote >= iv_seq) { -rl_printf ("Replayed message detected " +bt_shell_printf ("Replayed message detected " "(%016" PRIx64" >= %016" PRIx64")\n" , iv_seq_remote, iv_seq);return ;
mesh/onoff-model.c +32 -56
206 lines not on this page · raw message
mesh/prov-db.c +12 -13
@@ -37,11 +37,10 @@#include <json-c/json.h> #include <sys/stat.h> -#include <readline/readline.h> #include <glib.h> #include "src/shared/util.h" -#include "client/display.h" +#include "src/shared/shell.h" #include "mesh/mesh-net.h" #include "mesh/crypto.h"
@@ -83,7 +82,7 @@ static char* prov_file_read(const char *filename) sz =read (fd, str, st.st_size);if (sz != st.st_size) -rl_printf ("Incomplete read: %d vs %d\n" , (int )sz, +bt_shell_printf ("Incomplete read: %d vs %d\n" , (int )sz, (int )(st.st_size));close (fd);
@@ -104,7 +103,7 @@ static void prov_file_write(json_object *jmain, bool local) outfile =fopen (out_filename,"wr" );if (!outfile) { -rl_printf ("Failed to open file %s for writing\n" , out_filename); +bt_shell_printf ("Failed to open file %s for writing\n" , out_filename);return ; }
@@ -577,10 +576,10 @@ void prov_db_print_node_composition(struct mesh_node *node) done:if (res) -rl_printf ("\tComposition data for node %4.4x %s\n" , +bt_shell_printf ("\tComposition data for node %4.4x %s\n" , primary, comp_str);else -rl_printf ("\tComposition data for node %4.4x not present\n" , +bt_shell_printf ("\tComposition data for node %4.4x not present\n" , primary);g_free (in_str);
@@ -1380,7 +1379,7 @@ bool prov_db_show(const char *filename)if (!str)return false; -rl_printf ("%s\n" , str); +bt_shell_printf ("%s\n" , str);g_free (str);return true; }
@@ -1415,7 +1414,7 @@ static bool read_json_db(const char *filename, bool provisioner, bool local)json_object_object_get_ex (jmain,"node" , &jnode);if (!jnode) { -rl_printf ("Cannot find \"node\" object" ); +bt_shell_printf ("Cannot find \"node\" object" ); goto done; }else result =parse_node (jnode, true);
@@ -1451,7 +1450,7 @@ static bool read_json_db(const char *filename, bool provisioner, bool local) goto done; len =json_object_array_length (jarray); -rl_printf ("# netkeys = %d\n" , len); +bt_shell_printf ("# netkeys = %d\n" , len);for (i =0 ; i < len; ++i) {uint32_t idx;
@@ -1489,7 +1488,7 @@ static bool read_json_db(const char *filename, bool provisioner, bool local)json_object_object_get_ex (jmain,"appKeys" , &jarray);if (jarray) { len =json_object_array_length (jarray); -rl_printf ("# appkeys = %d\n" , len); +bt_shell_printf ("# appkeys = %d\n" , len);for (i =0 ; i < len; ++i) {int app_idx;
@@ -1536,7 +1535,7 @@ static bool read_json_db(const char *filename, bool provisioner, bool local) goto done; len =json_object_array_length (jarray); -rl_printf ("# provisioners = %d\n" , len); +bt_shell_printf ("# provisioners = %d\n" , len);for (i =0 ; i < len; ++i) {
@@ -1550,7 +1549,7 @@ static bool read_json_db(const char *filename, bool provisioner, bool local) }if (!parse_unicast_range (jtemp)) { -rl_printf ("Doneed to parse unicast range\n" ); +bt_shell_printf ("Doneed to parse unicast range\n" ); goto done; } }
@@ -1563,7 +1562,7 @@ static bool read_json_db(const char *filename, bool provisioner, bool local) len =json_object_array_length (jarray); -rl_printf ("# provisioned nodes = %d\n" , len); +bt_shell_printf ("# provisioned nodes = %d\n" , len);for (i =0 ; i < len; ++i) {json_object *jnode; jnode =json_object_array_get_idx (jarray, i);
mesh/prov.c +8 -8
@@ -38,10 +38,10 @@#include "src/shared/util.h" #include "src/shared/ecc.h" +#include "src/shared/shell.h" #include "gdbus/gdbus.h" #include "monitor/uuid.h" -#include "client/display.h" #include "mesh/node.h" #include "mesh/gatt.h" #include "mesh/crypto.h"
@@ -178,9 +178,9 @@ bool prov_open(struct mesh_node *node, GDBusProxy *prov_in, uint16_t net_idx, prov->conf_in.invite.attention = invite[2 ]; prov->state =PROV_INVITE ; -rl_printf ("Open-Node: %p\n" , node); -rl_printf ("Open-Prov: %p\n" , prov); -rl_printf ("Open-Prov: proxy %p\n" , prov_in); +bt_shell_printf ("Open-Node: %p\n" , node); +bt_shell_printf ("Open-Prov: %p\n" , prov); +bt_shell_printf ("Open-Prov: proxy %p\n" , prov_in);return mesh_gatt_write (prov_in, invite,sizeof (invite),NULL , node); }
@@ -380,7 +380,7 @@ static void prov_calc_ecdh(DBusMessage *message, void *node)"Enter %s on device\n" , in_ascii); } -rl_printf ("Agent String: %s\n" , in_oob_display); +bt_shell_printf ("Agent String: %s\n" , in_oob_display);agent_output_request (in_oob_display);break ; }
@@ -436,7 +436,7 @@ bool prov_data_ready(struct mesh_node *node, uint8_t *buf, uint8_t len) buf++; len--; -rl_printf ("Got provisioning data (%d bytes)\n" , len); +bt_shell_printf ("Got provisioning data (%d bytes)\n" , len);if (buf[0 ] >PROV_FAILED || expected_pdu_size[buf[0 ]] != len)return prov_complete (node,PROV_ERR_INVALID_PDU );
@@ -611,7 +611,7 @@ bool prov_data_ready(struct mesh_node *node, uint8_t *buf, uint8_t len)return prov_complete (node,PROV_ERR_INVALID_PDU ); -rl_printf ("Confirmation Validated\n" ); +bt_shell_printf ("Confirmation Validated\n" );prov_send_prov_data (node);
@@ -630,7 +630,7 @@ bool prov_data_ready(struct mesh_node *node, uint8_t *buf, uint8_t len)/* Compose appropriate reply for the prov state message */ /* Send reply via mesh_gatt_write() */ /* If done, call prov_done calllback and free prov housekeeping data */ -rl_printf ("Got provisioning data (%d bytes)\n" , len); +bt_shell_printf ("Got provisioning data (%d bytes)\n" , len);print_byte_array ("\t" , buf, len);return true;
mesh/util.c +14 -165
230 lines not on this page · raw message
mesh/util.h +1 -15
@@ -27,21 +27,7 @@ struct mesh_publication;#define OP_UNRELIABLE 0x0100 -struct menu_entry { -const char *cmd; -const char *arg; -void (*func) (const char *arg); -const char *desc; -}; - -bool cmd_menu_init (const struct menu_entry *cmd_table); -void cmd_menu_main (bool forced); -bool add_cmd_menu (const char *name,const struct menu_entry *cmd_table); -bool switch_cmd_menu (const char *name); -void set_menu_prompt (const char *prefix,const char * node); -void process_menu_cmd (const char *cmd,const char *arg); -void print_cmd_menu (const struct menu_entry *cmd_table); -void cmd_menu_cleanup (void ); +void set_menu_prompt (const char *name,const char *id);void print_byte_array (const char *prefix,const void *ptr,int len);bool str2hex (const char *str,uint16_t in_len,uint8_t *out_buf,uint16_t out_len);
Signature · 1 line
2.13.6
Luiz Augusto von Dentz
maintainerPATCH 3/4 tools/obexctl: Use bt_shell helpers
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This makes obexctl use bt_shell to manage the menus and command handling.
--- Makefile.tools | 5 +- tools/obexctl.c | 609 ++++++++++++++++---------------------------------------- 2 files changed, 175 insertions(+), 439 deletions(-)
Makefile.tools +2 -3
@@ -394,9 +394,8 @@ tools_bluetooth_player_SOURCES = tools/bluetooth-player.c \ tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline -tools_obexctl_SOURCES = tools/obexctl.c \ - client/display.h client/display.c -tools_obexctl_LDADD = gdbus/libgdbus-internal.la \ +tools_obexctl_SOURCES = tools/obexctl.c +tools_obexctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c
tools/obexctl.c +173 -436
1,445 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [PATCH BlueZ 3/4] tools/obexctl: Use bt_shell helpers
Hi Luiz,
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This makes obexctl use
bt_shellto manage the menus and command handling.--- Makefile.tools | 5 +- tools/obexctl.c | 609 ++++++++++++++++---------------------------------------- 2 files changed, 175 insertions(+), 439 deletions(-)
The previous obexctl gives arguments included a command name to the command, but bt_shell gives arguments excluded a command name. So you should fix argc/argv related processes in each command. Also bt_shell automatically checks passed arguments.
You can refer to the attached patch about these things.
Regards,
Eramoto
Makefile.tools +2 -3
@@ -395,9 +395,8 @@ tools_bluetooth_player_SOURCES = tools/bluetooth-player.c \ tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline -tools_obexctl_SOURCES = tools/obexctl.c \ - client/display.h client/display.c -tools_obexctl_LDADD = gdbus/libgdbus-internal.la \ +tools_obexctl_SOURCES = tools/obexctl.c +tools_obexctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c
tools/obexctl.c +191 -564
1,553 lines not on this page · raw message
Re: [PATCH BlueZ 3/4] tools/obexctl: Use bt_shell helpers
Hi,
Quoted 8 lines · ERAMOTO Masaya
Quoted 6 lines · Luiz Augusto von Dentz
This makes obexctl use
bt_shellto manage the menus and command handling.--- Makefile.tools | 5 +- tools/obexctl.c | 609 ++++++++++++++++---------------------------------------- 2 files changed, 175 insertions(+), 439 deletions(-)
Quoted 5 lines
The previous obexctl gives arguments included a command name to the command, but
bt_shellgives arguments excluded a command name. So you should fix argc/argv related processes in each command. Alsobt_shellautomatically checks passed arguments.
You can refer to the attached patch about these things.
If you ask me, I think we should keep this consistent with obexctl and e.g. how main() gets called. I.e. argv[0] is the command. An added benefit of this is that two very similar commands (taking the same parameters) can use the same command handler, since they'll be able to distuinguish which command was used.
Johan
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 3/4] tools/obexctl: Use bt_shell helpers
Hi Eramoto, Johan,
Quoted 17 lines · Johan Hedberg
Hi,
Quoted 8 lines · ERAMOTO Masaya
Quoted 6 lines · Luiz Augusto von Dentz
This makes obexctl use
bt_shellto manage the menus and command handling.--- Makefile.tools | 5 +- tools/obexctl.c | 609 ++++++++++++++++---------------------------------------- 2 files changed, 175 insertions(+), 439 deletions(-)Quoted 5 lines
The previous obexctl gives arguments included a command name to the command, but
bt_shellgives arguments excluded a command name. So you should fix argc/argv related processes in each command. Alsobt_shellautomatically checks passed arguments.
You can refer to the attached patch about these things.
Quoted 5 lines
If you ask me, I think we should keep this consistent with obexctl and e.g. how
main()gets called. I.e. argv[0] is the command. An added benefit of this is that two very similar commands (taking the same parameters) can use the same command handler, since they'll be able to distuinguish which command was used.
Yep, lets keep the command name then and fix bluetoothctl.
Signature · 1 line
Luiz Augusto von Dentz
Luiz Augusto von Dentz
maintainerPATCH 4/4 tools/bluetooth-player: Use bt_shell helpers
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This makes bluetooth-player use bt_shell to manage the menus and command handling.
--- Makefile.tools | 4 +- tools/bluetooth-player.c | 473 +++++++++++------------------------------------ 2 files changed, 111 insertions(+), 366 deletions(-)
Makefile.tools +2 -2
@@ -389,9 +389,9 @@ tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \ tools/obex-server-tool.c tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@ -tools_bluetooth_player_SOURCES = tools/bluetooth-player.c \ - client/display.h client/display.c +tools_bluetooth_player_SOURCES = tools/bluetooth-player.c tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \ + src/libshared-glib.la \ @GLIB_LIBS@ @DBUS_LIBS@ -lreadline tools_obexctl_SOURCES = tools/obexctl.c
tools/bluetooth-player.c +109 -364
997 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [PATCH BlueZ 4/4] tools/bluetooth-player: Use bt_shell helpers
Hi Luiz,
Quoted 9 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This makes bluetooth-player use
bt_shellto manage the menus and command handling.--- Makefile.tools | 4 +- tools/bluetooth-player.c | 473 +++++++++++------------------------------------ 2 files changed, 111 insertions(+), 366 deletions(-)
Probably, bluetooth-player has the similar problem as obexctl.
Regards,
Eramoto