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

Sending data before pairing

I have a timer that sends BLE data to a central every 5 seconds. The timers starts immediately out of reset. Until I actually pair the devices, the nRF51822 outputs an error message NRF_ERROR_INVALID_STATE when it tries to send the data. I understand that it is because I'm trying to send data before the two are paired, but how do I test if that pairing has been done?

Parents
  • I should have been more clear. I am using Master Control Panel. When I click on "Service Discovery" this generates the BLE_GAP_EVT_CONNECTED event. That is where I currently start my timers to send data to MCP. Then I get the NRF_ERROR_INVALID_STATE error for each characteristic that I send. Once I click "Enable Services" in MCP, those messages stop. I put a break point in the on_ble_evt(ble_evt_t * p_ble_evt) function. Clicking "Enable Services" seems to create a BLE_GATTS_EVT_WRITE event. This is a very generic write event.

    What I want to do is not try sending data until services are enabled so the NRF_ERROR_INVALID_STATE is not generated. How do I do this? Is this error a non-issue? Is there an event that I should be checking for that I am missing?

Reply
  • I should have been more clear. I am using Master Control Panel. When I click on "Service Discovery" this generates the BLE_GAP_EVT_CONNECTED event. That is where I currently start my timers to send data to MCP. Then I get the NRF_ERROR_INVALID_STATE error for each characteristic that I send. Once I click "Enable Services" in MCP, those messages stop. I put a break point in the on_ble_evt(ble_evt_t * p_ble_evt) function. Clicking "Enable Services" seems to create a BLE_GATTS_EVT_WRITE event. This is a very generic write event.

    What I want to do is not try sending data until services are enabled so the NRF_ERROR_INVALID_STATE is not generated. How do I do this? Is this error a non-issue? Is there an event that I should be checking for that I am missing?

Children
No Data
Related