I am developing an application using a low power BLE device based on the CyBLE 214009-000 module, and a windows program using c# and the CySmart API Started from the published example).
Most of the app is written and works, including reading and setting ports, getting A/D info both reading and by notification and I am now (belatedly!) exploring the low power behavior of the device. Both firmware and software are getting a bit sizeable, so I am not going to post the entire thing, but if someone wants more details about some aspect please let me know and I will try and reduce to a managable size and still demonstrate that aspect.
I have two problems, one around the behaviour of CySmart, and one on the behavior of C#.
1) The CySmart application removes the "connected" tic when the peripheral is timed out.
I would like to do the same in order to manage the graceful degredation of the link, and show the user (me!) what is going on. However I cannot find any way of achieving this directly using the CySmart API to interrogate the status of the connection. Is there an elegant way to do this or does it have to be achieved using timers and then monitoring the return of a packet request somehow?
2) I want part of the app functionaliy to allow a user to nominate a specic device address from the scan list, after which that device will automatically be connected when it it is seen in the scan list.
The code has been written to take a focused device address and place it in escrow. When a button is pressed to restart the scan the code compares each device as it is scanned with the device address in escrow. If a match is found the scan continues to completion. Another button is then used to take the escrow address and creates the connection. All this works, but if I move the creation of the connection into the scanning code I end up in horrible issues with null pointers or getting locked in unresolved wait states. I have tried forcing a button click for the button that works, embedding the code into the scan routine or at various places further down line from that point, and even using global flags to try and force it from the main program loop...... all failed with the same problems.
This seems to be because the call to "BLEManager.Connect(new CyConnectInfo(PEER_DEVICE_BD_ADDR, new CyBleConnectionSettings()));" results in a callback to the "BLEManagerCallBack.ConnectionHandler" (which "sets" an essential AutoResetEvent) if the code is run from a Form control event, but not if the routine is called from any other place. I cannot follow the program execution here as it is hidden inside the API. I know this is a bit specific but any general thoughts and or comments might get me started again!
Any and all comments or suggestions very welcome!