This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to detect peripheral connect but not enable notify yet

Hi,

I do test my project one central connect to 4 peripheral(HR and CSC). and I put the memset(&m_ble_db_discovery,0,sizeof(m_ble_db_discovery)); err_code = ble_db_discovery_start(&m_ble_db_discovery[p_gap_evt->conn_handle], p_gap_evt->conn_handle); APP_ERROR_CHECK(err_code); so central connect to peripheral works fine but during my test I will switch off central device power off. I found my peripheral keep connect because the led on and no advertising. The peripheral is use the pca10028 evb.

So I step by step running my central side I found after ble_db_discovery_start function is called but no keep call ble_cscs_c_handles_assign and after other functions the peripheral device will turn on the LED1 means BLE_GAP_EVT_CONNECTED is show and keep wait.

My question is: how to detect my peripheral device even though the BLE_GAP_EVT_CONNECTED is show but during few seconds still no enable notify service then disconnect and advertising for other central device.

Thanks

Parents
  • Finally I realize how to got the notify does enable or not

    1. Assign the service handle into service_init for example in csc device:

      void m_ble_cscs_evt_handler_t (ble_cscs_t * p_cscs, ble_cscs_evt_t * p_evt) { if( p_evt->evt_type == BLE_CSCS_EVT_NOTIFICATION_ENABLED ) { NRF_LOG_INFO("BLE_CSCS_EVT_NOTIFICATION_ENABLED\r\n"); } else if( p_evt->evt_type == BLE_CSCS_EVT_NOTIFICATION_DISABLED ) { NRF_LOG_INFO("BLE_CSCS_EVT_NOTIFICATION_DISABLED\r\n"); } }

      static void services_init(void) { uint32_t err_code; ble_cscs_init_t cscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; ble_sensor_location_t sensor_location;

       // Initialize Cycling Speed and Cadence Service.
      memset(&cscs_init, 0, sizeof(cscs_init));
      
      cscs_init.evt_handler = m_ble_cscs_evt_handler_t;//NULL;
      

    then we can got the notify does enable or not.

Reply
  • Finally I realize how to got the notify does enable or not

    1. Assign the service handle into service_init for example in csc device:

      void m_ble_cscs_evt_handler_t (ble_cscs_t * p_cscs, ble_cscs_evt_t * p_evt) { if( p_evt->evt_type == BLE_CSCS_EVT_NOTIFICATION_ENABLED ) { NRF_LOG_INFO("BLE_CSCS_EVT_NOTIFICATION_ENABLED\r\n"); } else if( p_evt->evt_type == BLE_CSCS_EVT_NOTIFICATION_DISABLED ) { NRF_LOG_INFO("BLE_CSCS_EVT_NOTIFICATION_DISABLED\r\n"); } }

      static void services_init(void) { uint32_t err_code; ble_cscs_init_t cscs_init; ble_bas_init_t bas_init; ble_dis_init_t dis_init; ble_sensor_location_t sensor_location;

       // Initialize Cycling Speed and Cadence Service.
      memset(&cscs_init, 0, sizeof(cscs_init));
      
      cscs_init.evt_handler = m_ble_cscs_evt_handler_t;//NULL;
      

    then we can got the notify does enable or not.

Children
No Data
Related