mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
examples: parse command line args only if HAVE_POSIX_STDIN, don't call exit()
This commit is contained in:
parent
f22209df62
commit
eb8fc74029
@ -291,7 +291,7 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
|
||||
if (cmdline_addr_found){
|
||||
printf("\nDisconnected %s\n", bd_addr_to_str(cmdline_addr));
|
||||
exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\nDisconnected %s\n", bd_addr_to_str(report.address));
|
||||
@ -304,14 +304,17 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_POSIX_STDIN
|
||||
static void usage(const char *name){
|
||||
fprintf(stderr, "\nUsage: %s [-a|--address aa:bb:cc:dd:ee:ff]\n", name);
|
||||
fprintf(stderr, "If no argument is provided, GATT browser will start scanning and connect to the first found device.\nTo connect to a specific device use argument [-a].\n\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
#ifdef HAVE_POSIX_STDIN
|
||||
int arg = 1;
|
||||
cmdline_addr_found = 0;
|
||||
|
||||
@ -326,6 +329,10 @@ int btstack_main(int argc, const char * argv[]){
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
#endif
|
||||
|
||||
hci_event_callback_registration.callback = &hci_event_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
|
@ -201,7 +201,6 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
||||
break;
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
printf("\nGATT browser - DISCONNECTED\n");
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -266,14 +265,17 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
||||
}
|
||||
/* LISTING_END */
|
||||
|
||||
#ifdef HAVE_POSIX_STDIN
|
||||
static void usage(const char *name){
|
||||
fprintf(stderr, "\nUsage: %s [-a|--address aa:bb:cc:dd:ee:ff]\n", name);
|
||||
fprintf(stderr, "If no argument is provided, GATT browser will start scanning and connect to the first found device.\nTo connect to a specific device use argument [-a].\n\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
#ifdef HAVE_POSIX_STDIN
|
||||
int arg = 1;
|
||||
cmdline_addr_found = 0;
|
||||
|
||||
@ -287,6 +289,10 @@ int btstack_main(int argc, const char * argv[]){
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
#endif
|
||||
|
||||
gatt_client_setup();
|
||||
|
||||
|
@ -169,7 +169,6 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
|
||||
break;
|
||||
case SDP_EVENT_QUERY_COMPLETE:
|
||||
printf("General query done with status %d.\n\n", sdp_event_query_complete_get_status(packet));
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user