/**@brief Function for handling the Application's BLE Stack events. * * @param[in] p_ble_evt Bluetooth stack event. */ static void on_ble_evt(ble_evt_t * p_ble_evt) { uint32_t err_code; print_evt(p_ble_evt); // Print event to RTT switch (p_ble_evt->header.evt_id) // Handle events { case BLE_GAP_EVT_CONNECTED: err_code = bsp_indication_set(BSP_INDICATE_CONNECTED); // Light LED_1 continuously when connected APP_ERROR_CHECK(err_code); m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; // Set connection handle break; case BLE_GAP_EVT_DISCONNECTED: m_conn_handle = BLE_CONN_HANDLE_INVALID; // Set connection handle to 0xFFFF break; default: // No implementation needed. break; } }
int main(int argc, char **argv) { int c, i; int interval = 1; /* Interval between displays */ int count = 0; /* Number of times to sample */ int write_evts = FALSE; int pos = 0; #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif /* For I18N */ (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); pgmname = basename(argv[0]); if ((kc = kstat_open()) == NULL) { (void) fprintf(stderr, gettext("%s: could not " "open /dev/kstat\n"), pgmname); exit(1); } while ((c = getopt(argc, argv, "e:w:r:ahln")) != EOF) { switch (c) { case 'a': delta = FALSE; break; case 'e': (void) print_evt(); break; case 'h': usage(); break; case 'l': (void) print_dev(argc, argv[argc-1]); break; case 'n': banner = FALSE; break; case 'r': (void) parse_cmd(READ_EVT); break; case 'w': (void) parse_cmd(WRITE_EVT); write_evts = TRUE; break; default: (void) fprintf(stderr, gettext("%s: invalid " "option\n"), pgmname); usage(); break; } } if ((argc == 1) || (dev_list_head == NULL)) usage(); /* * validate remaining operands are numeric. */ pos = optind; while (pos < argc) { if (strisnum(argv[pos]) == 0) { (void) fprintf(stderr, gettext("%s: syntax error\n"), pgmname); usage(); } pos++; } if (optind < argc) { if ((interval = atoi(argv[optind])) == 0) { (void) fprintf(stderr, gettext("%s: invalid " "interval value\n"), pgmname); exit(1); } optind++; if (optind < argc) if ((count = atoi(argv[optind])) <= 0) { (void) fprintf(stderr, gettext("%s: " "invalid iteration value.\n"), pgmname); exit(1); } } set_timer(interval); /* * Set events for the first time. */ if (write_evts == TRUE) setup_evts(); if (count > 0) { for (i = 0; i < count; i++) { if (banner) print_banner(); check_dr_ops(); read_evts(); (void) fflush(stdout); (void) pause(); } } else { for (;;) { if (banner) print_banner(); check_dr_ops(); read_evts(); (void) fflush(stdout); (void) pause(); } } read_evts(); return (0); }