Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
How can I force disconnection from nrf51822 with BLE API?
I want to disconnect peripheral device once the data is sent by it. how can I do that? I did not find API. I want that peripheral disconnects or disconnects forcefully. after the required data is sent.
1 Answer
9 years, 1 month ago.
Hello Shirish,
You have answered your own question. It is the correct way to do it.
ok I found out how to do this. But I am not sure if this is the right way to do this???
disconnect on unknown mac-id
void connectionCallBack(const Gap::ConnectionCallbackParams_t* params) { Serial.print(" The peerAddr : "); for(uint8_t index=0; index<6; index++) { Serial.print(params->peerAddr[index], HEX); Serial.print(" "); } //check the mac id what every you saved or know you want to only connect to. if( !(params->peerAddr[0]!=0xf9 || params->peerAddr[0]!=0xf9 || params->peerAddr[0]!=0xf9 params->peerAddr[0]!=0xf9 || params->peerAddr[0]!=0xf9 || params->peerAddr[0]!=0xf9)) { //this is not the allowed Device. disconnect. Serial.println("not the device we want"); Gap::DisconnectionReason_t res=Gap::LOCAL_HOST_TERMINATED_CONNECTION; ble.disconnect(params->handle,res ); } }