I have successfully establish a connection and normally I can able to communicate between each other but in my case I need to send a message to the centrals when in onConnectionStateChange callback newState is BluetoothProfile.STATE_CONNECTED(callback is fine)this process or step is not working. I have added a delay of 1500 milliseconds but didn't work. If I do the same thing from central after onDiscovery get called then I can send message to the peripheral and peripherals also now able to send messages to centrals
val callback = object : BluetoothGattServerCallback(){
override fun onConnectionStateChange(device: BluetoothDevice?, status: Int, newState: Int) {
super.onConnectionStateChange(device, status, newState)
when(newState){
BluetoothProfile.STATE_CONNECTED->{
// This callback is working fine and I got the Connection status OK
// Here first I want to notify the centrals by sending a message.
}
}
}
}
Thanks to all.