- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to change from a defined custom profile to the observer or broadcaster role.
Asked differently, can a custom profile have a broadcaster or observer function?
We have a product, using Cypress PSoC that has a Passkey customer settable 6 digit PIN, we have a fixed stack boot loader, and have a successful product at this time.
The customer has asked us to add a physical remote control, so we have designed a PSoC BLE remote control, push button, battery operated. We know we can have the remote act as a central, provide a PIN code, but they do not want the remotes to use up the pairing spaces, and there is no way to enter the customer settable pin into the remote control.
We think we can make the remote control a dynamic broadcaster, and the then turn the device being controlled from a peripheral/server device, into an observer, who will observe the dynamic payload of the remote control, when not connected to central.
Can this be done? Again, we have a custom profile, and we need to be able to dynamically switch between server, and an observer.
I have reviewed the 101 projects, 9-12, so i am concern that we cannot make the device under control a server broadcasting and accepting connection requests, and then switch to observer mode and look to see if one of the remote controls is broadcasting?
Thanks for any help or direction.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Can you please refer to the attached demo project where I'm switching between server and observer.
In the project, BLE component is configured in Central and Peripheral GAP role. Initially device advertises and can connects with the central device. There was a switch interrupt in the project, whenever the switch was pressed for first time device will get disconnected and when the switch was pressed for second time scanning starts. For the Observer role, following code was added in firmware after disconnection.
cyBle_discoveryInfo.discProcedure=CYBLE_GAPC_OBSER_PROCEDURE;
CyBle_GapcStartScan();
Please let me know if this helps.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Can you please refer to the Day007_Peripheral_and_Broadcaster example project in the GitHub. In this example the device is a Peripheral in an active connection and is also a Broadcaster at the same time.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
P. Yugandhar, thank you for your reply, unfortunately you have misread our question, pasted again here:
We have a custom profile, and we need to be able to dynamically switch between server, and an observer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Can you please refer to the attached demo project where I'm switching between server and observer.
In the project, BLE component is configured in Central and Peripheral GAP role. Initially device advertises and can connects with the central device. There was a switch interrupt in the project, whenever the switch was pressed for first time device will get disconnected and when the switch was pressed for second time scanning starts. For the Observer role, following code was added in firmware after disconnection.
cyBle_discoveryInfo.discProcedure=CYBLE_GAPC_OBSER_PROCEDURE;
CyBle_GapcStartScan();
Please let me know if this helps.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes this worked, thank you very much. To recap, I have a psocBLE remote control, when active is sends one scan response, when a button is pressed a different response is sent.
Now here is the new issue, when I transfer the code to my actual project, I cannot compile any of the GAPC commands. We are doing a fixed stack bootloader, and the BLE element is in the Bootloader program, but it is set just like the one in your example, except for security, we have pairing and bonding enabled.
Any ideas? Again, your program worked, and I can scan and read my remote, but when transferring to my project any command with GAPC generates a build error and undefined reference?
Bundle attached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Herb,
At my end the project is building fine with the commands GAPC. Please let me know if I'm missing anything.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is confusing then, here is the output when I do a clean and build of the same project
How can that be, that you can build it, but I cannot?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you build both projects, bootloader and BoatLiftBoss, if you only built the bootloader, it does not have the code that is failing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Herb,
The errors for the APIs are because the Bootloadable project don't have the definitions of these APIs. So we have to KEEP the APIs in the linker script. Thus definitions of the APIs will be taken from the bootloader project. For this, first KEEP the APIs in the script file cm0gcc.ld. Set the bootloader project active. Open cm0gcc.ld file in Bootloader project. Add the KEEP APIs as shown in attached image. Then save and build the project and run mk.bat file.
Please let me know if this helps.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I found how to include the commands, when you are using a fixed stack bootloader you have to have the commands in the bootloader program to make them work in the bootloadable program, how goofy is that!
Now we are on the next step of the problem, once it starts scanning the main loop crashes, the WDT continues to run, but the main loops locks up?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please refer to the attached modified project.
Please refer to the below points.
1. Don't write big code inside any ISR. Instead, set a variable inside ISR and check the variable status and call the function in main loop.
2. Always keep the Bless interrupt to highest priority i.e., bless interrupt priority to 0.
3. Please clear the WDT interrupt properly after completion using CySysWdtClearInterrupt(), this function will Clears all the WDT counter interrupts set in the mask.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PY, your responses leave me concerned, the project you sent back had the same issue, scanning crashed.
in response to your suggestions.
1. Which ISR are you referring to, we have a simple tool and no power issues, i am scanning, not using ISRs? The only two interrupts active in my system is WDT and ADC, are you suggesting that the WDT code is too long?
2. We do not have BLESS implemented, we are running from a power supply and AC mains, no need for low power at all
3. The clear function was at the bottom of the ISR, so that it would not hit again until I was complete
What did you change, I am having a hard time find anything but a duplicate CySysWdtClearInterrupt(WDT_INTERRUPT_SOURCE); in the WDT ISR?
Herb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just found and fixed the issues, there were three of them,
1. The scan parameters were not set correctly in the BLE configuration tool, I changed the scan window and interval to defaults
2. The was an incorrect function close in the WDT routine
3. I was not stopping advertising before starting to scan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I could really use some help now, the unit will not advertise, not sure why.
Should I be putting it into different modes?
cyBle_discoveryInfo.discProcedure=CYBLE_GAP_ROLE_PERIPHERAL; // this did not work, it still would not advertise
The scanning works well and I can pick up the broadcasts I want.
But it will never advertise? Can you help?
bundle attached
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, that got advertising working again, but I still have an issue, I am trying to switch back and fourth between scanning and advertising,.
I start advertising, the switch to scanning, the go back to advertising and get a CYBLE_INVALID_STATE error when switching back to advertising.
It appears I am missing something when switching roles and tasks, please help me understand how to put the unit in two different states, and switch back and fourth?
1. Advertising and ready to connect as a peripheral
2. Observing and scanning for advertisements
3. How to dynamically switch between the two
Code and error messages:
void ScanControl(void)
{
sysState = CyBle_GetState();
if((scanFlag == FALSE)&&(deviceConnected == FALSE)&&(CyBle_GetState() != CYBLE_STATE_ADVERTISING))
{
CyBle_GapcStopScan();
cyBle_discoveryModeInfo.discMode=CYBLE_GAPP_GEN_DISC_MODE;
apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
CyBle_ProcessEvents();
DBG_PRINTF("\t\t\t\t\t\t\t\t\t\tStartAdvertisement API Error: %d\r\n", apiResult);
}
if((scanFlag == TRUE)&&(deviceConnected == FALSE)&&(CyBle_GetState() != CYBLE_STATE_SCANNING))
{
CyBle_GappStopAdvertisement();
cyBle_discoveryInfo.discProcedure=CYBLE_GAPC_OBSER_PROCEDURE;
apiResult = CyBle_GapcStartScan(CYBLE_SCANNING_FAST);
CyBle_ProcessEvents();
DBG_PRINTF("\t\t\t\t\t\t\t\t\t\tScanning %d \n\r", apiResult);
}
}
StartAdvertisement API Error: 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
STOP Command Turning Light OFF Scanning 0
CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
eventType:Connectable undirected advertising
peerAddrType: RANDOM
peerBdAddr: 7bf572fdd8a8
Peer device adveritsing/scan response data Length: e
advertising/scan response data of peer device:
ÿL@1'
Rssi: -79
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Light OFF StartAdvertisement API Error: 259
STOP Command Turning Li