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

Bluetooth automatic reconnection nRF51

Hi, The situation: nRF51 has established a connection with the iOS/Android (custom made)App. The nRF51 goes out of the Bluetooth range. Eventually, the Bluetooth connection is disconnected. The nRF51 comes into the Bluetooth range. The App reconnects with the nRF51 automatically. The nRF51 receives BLE_GAP_EVT_CONNECTED event and upon reception of this event, the nRF51 sends initial data to be populated in the characteristics of the App. The nRF51 keeps sending initial data to be populated until it receives the BLE_EVT_TX_COMPLETE event from the App (meaning the App has received the info sent by the nRF51). But, for some reason,(from the logs of the App), the App (tested with iOS) doesnot receive this initial data. If nRF51 sends out initial data continuously for 300 times in a row, then, the App receives the last 5 attempts(the 295 attempts are lost!). Instead of using the magic number 300, what is the proper way of populating the characteristics of the App upon reconnection? PS: If in the App, the connection is deliberately disconnected and reconnected, then, the App receives the initial data to be populated. The problem occurs only upon automatic reconnection.

Parents
  • Hi Jorgen, Sorry, I didn't explain it properly. Even when I send sd_ble_gatts_hvx() upon reconnection, I do get the BLE_EVT_TX_COMPLETE, but in the XCode logs of the (custom made)App, there is no indication that it has received a data from the nRF51. But when I keep sending the same data 300 times, then, the XCode logs of the app says that it has received 5 of the data (didn't receive all the 300). I think it is something to do with the way the app handles reconnection with Bluetooth. Because, when I close the app and reopen it again(which is a compete disconnection and a new connection - not reconnection), the XCode logs says that it has received data from the nRF51 (nRF51 sent the data only once upon new bluetooth connection). From nRF51 point of view, reconnection or new connection is the same - which is BLE_EVT_CONNECTED, so if the app can receive data from nRF51 upon a new conection, it has to receive data upon reconnection, as well, isn't it?

Reply
  • Hi Jorgen, Sorry, I didn't explain it properly. Even when I send sd_ble_gatts_hvx() upon reconnection, I do get the BLE_EVT_TX_COMPLETE, but in the XCode logs of the (custom made)App, there is no indication that it has received a data from the nRF51. But when I keep sending the same data 300 times, then, the XCode logs of the app says that it has received 5 of the data (didn't receive all the 300). I think it is something to do with the way the app handles reconnection with Bluetooth. Because, when I close the app and reopen it again(which is a compete disconnection and a new connection - not reconnection), the XCode logs says that it has received data from the nRF51 (nRF51 sent the data only once upon new bluetooth connection). From nRF51 point of view, reconnection or new connection is the same - which is BLE_EVT_CONNECTED, so if the app can receive data from nRF51 upon a new conection, it has to receive data upon reconnection, as well, isn't it?

Children
No Data
Related