Browse Source

update

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
3ca8704138
  1. 16
      app/main.c
  2. 2
      app/src/zble_module.c

16
app/main.c

@ -40,6 +40,21 @@ void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
}
}
static void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context) {
uint32_t err_code;
switch (p_ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED:
ZLOGI("Connected");
break;
case BLE_GAP_EVT_DISCONNECTED:
ZLOGI("Disconnected");
// zble_module_start_adv();
break;
}
}
void on_service_init(void) {
/**
* @brief
@ -63,6 +78,7 @@ int main(void) {
.on_service_init = on_service_init,
};
zble_module_init(&cfg);
NRF_SDH_BLE_OBSERVER(m_ble_observer, 3, ble_evt_handler, NULL);
zble_module_start_adv();
zsys_loop();

2
app/src/zble_module.c

@ -62,12 +62,10 @@ static void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context) {
uint32_t err_code;
switch (p_ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED:
NRF_LOG_INFO("Connected");
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
NRF_LOG_INFO("Disconnected");
m_conn_handle = BLE_CONN_HANDLE_INVALID;
break;

Loading…
Cancel
Save