In BLE there is no profile exactly suitable for serial protocol. You will need to use custom profile. You can design the profile in such a way that Client perform reads periodically from the slave. Also note that simultaneous connection to multiple slaves is not possible, you will need to time multiplex.
Thanks For the answer,
I have implemented above scenario with heart rate collector and heart rate sensor and time multiplexing.
but i am facing some issue as below
2.sometimes peripheral device stops advertising/notification.
1. You need a larger encryption key size. This seems pretty self-explanatory?
2. Depending on how you write the peripheral BLESS event handler, you might run into an event where the chip does an event that causes it to stop advertising (based on code, since I haven't seen it lose advertisement without some event/notification/code telling it to).
I would suggest looking at your code flow and seeing if there are cases that could cause the advertisement to stop.
Also, just fyi, the notifications only work when the device is connected to another Bluetooth device; Notifications while unconnected shouldn't work, and this could be what you are seeing.
Thanks for the information i will go through it.
can you please go through the logs attached here and and figure out something?
2 different master logs(taken on separate days) and 1 slave log
Since most of the events are successes; I would assume there is something transient occurring in your code.
The insufficient encryption error has the following documentation:
/** Insufficient key size for the security requirements of this device */
Possibly, you are sometimes using the wrong value for the encryption key or encryption key size.
The following events make me think your code is behaving erratically (in Teraterm-master.txt):
Line 21: ConnectDevice API Error: 0x103 invalid state: state: scanning
Line 75: ConnectDevice API Error: 0x103 invalid state: state: connected
Line 91: ConnectDevice API Error: 0x103 invalid state: state: scanning
Line 168: CyBle_BascSetCharacteristicDescriptor API Error: 0x02 invalid operation
Thanks For the patience..!!
Can you please look(in Teraterm-master.txt): after Line 57967.
as main problem causes after this and am unable to figure out as you can see scan progress shows the peripheral devices(00a050000aaa/bbb/ccc/ddd) but unable to connect.
device-3 is anyhow down so i am getting CYBLE_EVT_TIMEOUT: 4
Then i get start getting CYBLE_EVT_GAP_AUTH_FAILED, reason: INSUFFICIENT_ENCRYPTION_KEY_SIZE and ConnectDevice API Error: 0x103 invalid state: state: scanning
for time being as a workaround am using "CySoftwareReset();" for the 60 sec on both side and planning to do same if encryption error comes.
is there any way to inform heart rate sensor about heart rate collector has resetted?or any workaround so that all devices will be in sync.
but don't feel this is a better way.
It looks like one of your connection attempts fails, after which your code/state machine gets out of wack and starts trying to connect while still scanning, etc.
Try adding handlers for failure cases for: connecting, scanning, reading data, encrypting, etc.
That way, you can say retry encryption a couple times if it fails; Reset the encryption data if it fails too much, etc.
I would say the code looks to be behaving in a time-multiplexing fashion, and you just need to handle the failure cases.