You can know the reason for the disconnection from the DISCONNECT event. Also, did you try restarting the advertisement after the disconnect event (inside the event callback or somewhere else)?
- Madhu Sudhan
1) Disconnection happens when the central device tries to establish the connection with peripheral.
2) Also tried to restart the advertisement once it disconnects, it comes to CYBLE_EVT_GATT_DISCONNECT_IND and stops advertising. Its not invoking CYBLE_EVT_GAP_DEVICE_DISCONNECTED event.
is there any way of restarting the ble?
Hi there, was there any resolution to this?
I'm running into the same issue when restarting advertising after using my device as a BLE central (stop advertising, connect, write, disconnect, re-advertise).
I can only re-advertise for a second before advertisements just stop.
I've noticed that when I remove sleep mode (ifdef'd out), everything works as expected.
Update: More specifically, only when I go into BLESS_DEEP_SLEEP do I run into the problem where advertisements stop. Regular BLESS SLEEP can still have functional advertisements.
Would it be possible for you to post the code that handles sleep/wake transitions in your application? I have seen this occur once when the testing conditions for whether to use normal sleep vs. deep sleep are not quite correct.
Hey Jeff, here is the sleep-only related code. I'm working on building an isolated application to test out just this issue I'm having. Will post it when I finish it.
It is run in the main loop just after ProcessEvents
sleep.txt.zip 1.2 K
Just as a note, I've pulled in a horrific workaround from Project052_BLE_Mesh_Directed. It says this workaround is there as a workaround for CDT 214662, and I don't know what that is.
Anyways, to recap, I have a state machine which runs through (and verifies the state of): Stop Advertising, Connect to peripheral via mac address, write a message, disconnect, start advertising.
When I have my device set to go into BLESS_DEEPSLEEP, that last advertising state would only send a few advertisements then go silent, and there was no way to recover. If I only went down into BLESS_SLEEP, then everything worked normally (but, doesn't matter when, if I EVER went back into DEEPSLEEP mode, advertisements stop).
The only workaround to the above scenario was to restart advertising, disable DEEPSLEEP mode, and stay in regular SLEEP. Then, after a phone connected to the device, and then disconnected - I was able to enter DEEPSLEEP again, and it seemed like everything worked correctly. So, there was something about acting like a peripheral, getting connected to, and then disconnecting that put us back in a good state.
Note: I have tried restarting advertisements in callbacks, in the event handlers, in the main loop, etc. I've also put ProcessEvents EVERYWHERE to no luck - the problem is outside of the trivial solutions unfortunately, it seems.
I've opened up a support ticket, but what I'm going with for now is that after I finish my (as a central) disconnection state, instead of re-advertising, I do a CyBle_Stop() then CyBle_Start(myEventHandler)... In my Initialization event handler, I restart advertisements - and all -seems- to work, but this is a pretty rough workaround.
I'll follow up if the support ticket shows a bug in my code, or a bug in the component. I hope it's in my code, not the component, because my code has already discovered a component bug that I need to put a workaround in the generated source for.
Any luck? Could it be something with the BLESS interrupt priority?