I started working with the Broadcast Observer project in this link.
I had it running on 2 BLE kits with 2 RealTerm windows. I could see both Advertisements received by the other board. Next I started to modify the project for my needs.
Test tool for device:
I want one of my projects to start up in Observer mode, look for an Advertisement from the other board by matching the blue tooth address, then switch to Broadcast to send a message out for TBD time (to allow the other board to receive it) which will include some device setting updates and then switch back to Observer. I was thinking I would use a Watchdog timer and when I received the interrupt I would switch back to Observer. This will be used as a test tool for testing the operation of my primary device.
The other board will be my primary device which will wake up from sleep from watchdog at 1s interval, Broadcast a message for TBD time, switch to Observer to see a message that includes setting updates, process the data, and then go back to sleep. If it doesn't receive a message in TBD time it will just go back to sleep until it is time to Advertise again. We don't want to connect to the device.
I have been able to get the Test tool project to start up in Observer mode, receive Advertise packets and match the blue tooth address. Then I try to stop the scan, but when I receive the CYBLE_EVT_GAPC_SCAN_START_STOP after I call CyBle_GapcStopScan() the device is in CYBLE_STATE_SCANNING state which I wasn't expecting. When I try to start advertising by calling CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST) I receive an CYBLE_ERROR_INVALID_STATE. I tried to do the stop scan and start advertise by setting a flag and processing in main and I also tried to do it after matching the blue tooth address in CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT instead of doing it in CYBLE_EVT_GAPC_SCAN_START_STOP but they also produce the same CYBLE_ERROR_INVALID_STATE state.
What am I doing wrong? I attached my project.
Solved! Go to Solution.