Communication between 2 BLE units

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

   

can me somebody help, please? I want to make the communication between 2 BLE units. One unit sends reguest (my data) to second unit. Than second unit sends the response (another data - my data).

   

I don¨t know, if each unit has to be defined as Client and Server unit or not.

   

Communication:  

   

1. first unit sends reguest (my data - combination of sensors)

   

2  second unit receives this data from first unit

   

3. second unit reads the sensor values

   

4. second unit sends data (sensor values)

   

5. first units receives data from first unit

   

I haven't find any example with this type of communication. In examples, there is only case, that client sends request and than server sends response. 

   

Thank you... 

0 Likes
1 Solution
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

As long as we are talking about the BLE GATT layer, one unit needs to be client and one the server. Typically the unit providing the values is the GATT server (your second unit). The client would write to a server attribute, indicating which sensors it wants to be read. Then the server provides values, probably via a notification.

   

But with BLE this is inefficient - actually the server should periodically read the sensors, and provide the values in its GATT attributes. When the client needs the values, it just reads the attributes and gets the current values.

View solution in original post

0 Likes
4 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

As long as we are talking about the BLE GATT layer, one unit needs to be client and one the server. Typically the unit providing the values is the GATT server (your second unit). The client would write to a server attribute, indicating which sensors it wants to be read. Then the server provides values, probably via a notification.

   

But with BLE this is inefficient - actually the server should periodically read the sensors, and provide the values in its GATT attributes. When the client needs the values, it just reads the attributes and gets the current values.

0 Likes
Anonymous
Not applicable

Thank You for answer. Unit with sensor will send values every 1s, otherside it will be deep sleep. My plan is to connect three unit  (slaves ) with sensors to one unit (master), which will process data from these units. For this case is better first or second variant?

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

The Cypress BLE stack can handle only one connection at a time, so your scenario will not work without some special logic (round-robin connection from the master to the slaves).

   

The second version is much more energy efficient. If you have a fixed timing, the sensor units can wake up once per second, read their sensor and then send a notification to the master.

Anonymous
Not applicable

So, I will use notify property. Can be the communication this way?

   

1.Client:  CyBle_GattcWriteCharacteristicValue 

   

2. Server accepts data in CyBle_GattsWriteRsp

   

3. Server sends ack connection:  CyBle_GattsWriteRsp

   

4. Server sends the notification (there is a new data): CyBle_GattsNotification

   

5. Client accepts data in CYBLE_EVT_GATTC_HANDLE_VALUE_NTF

   

OR

   

1.Client:  CyBle_GattcWriteCharacteristicValue 

   

2. Server accepts data in CyBle_GattsWriteRsp

   

4.Server sends the new data in the notification (without CyBle_GattsWriteRsp) : CyBle_GattsNotification

   

5. Client accepts data in CYBLE_EVT_GATTC_HANDLE_VALUE_NTF

   

It is a question, if I can send the new data in case CYBLE_EVT_GATTS_WRITE_REQ (I read data from client and send the data in the same time) with CyBle_GattsNotification?

0 Likes