Sending 3 int32 variables from server(EZ-BLE PROC module) to an iOS app

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

cross mob
Anonymous
Not applicable

Hello

   

I am new to cypress and am very exited to make my first custom ble profile.

   

I need to send 3 datasets that i capture from three sensors attached to the ez-ble module.

   

What is the best profile i can setup:

   

>Do i need to put each variable to a separate service?

   

>Do i need to have one only service and get 3 charcteristics for it which are the sensors values?

   

>Is the CYBLE_EVT_GATTS_WRITE_REQ event triggered when i have "write" or "notify" property in the characteristic?

   

One other important thing:

   

I have a temperature stored in int32, when i try to  write to the GATT database :

   

CYBLE_GATT_HANDLE_VALUE_PAIR_T tempsensorhandle;
                tempsensorhandle.attrHandle=CYBLE_TEMPSENSOR_TEMPSENSOR_SENSING_CHAR_HANDLE;
                tempsensorhandle.value.val=temperature;
                tempsensorhandle.value.len=sizeof(temperature);
            gattError= CyBle_GattsWriteAttributeValue(&wrReqParam->handleValPair,0,&cyBle_connHandle,CYBLE_GATT_DB_PEER_INITIATED);

   

I noticed that tempsensorhandle.value.val is an *int8 which cannot store my int32 temperature although i have declared it in32 in the ble configuration interface. Do i need to get every 8bit of my 32 bit integer to store it there?

0 Likes
1 Reply
Anonymous
Not applicable

Welcome to the forum!!

   

I would suggest you start with following reference materials:

   

1) If you are new to BLE as a whole, you can refer the application note AN91267 to understand a bit of the BLE and PSoC. Else, you cn skip it.

   

2) Refer the application note AN91162 (http://www.cypress.com/documentation/application-notes/an91162-creating-ble-custom-profile ). This application note will give you a comprehensive detail on how to handle BLE custom profiles/services on PSoC 4 BLE/PRoC BLE.

   

 

   

Now to your questions:

   

>Do i need to put each variable to a separate service?

   

[ROIT]: Your choice. If the sensors cumulatively provide one functionality, then support one service (such as X, Y, Z of an accelerometer). If each sensor has a different purpose (such as temperature, humidity, pressure), then you may go for different service. In the end, you have to read the data accordingly.

   

>Do i need to have one only service and get 3 charcteristics for it which are the sensors values?

   

[ROIT]: As I said, depends on the application and how you want to handle it. Everything boils down to reading/writing data on a characteristic.

   

>Is the CYBLE_EVT_GATTS_WRITE_REQ event triggered when i have "write" or "notify" property in the characteristic?

   

[ROIT]: Considering that you are a GATT Server, then yes, 'CYBLE_EVT_GATTS_WRITE_REQ ' is triggered when a write request or notification enable/disable is sent. Note that the actual notify is data going from Server to Client, so the event is triggered on the Client side. Same for Indications.

   

 

   

I noticed that tempsensorhandle.value.val is an *int8 which cannot store my int32 temperature although i have declared it in32 in the ble configuration interface. Do i need to get every 8bit of my 32 bit integer to store it there?

   

[ROIT]: Typically, yes. The input parameter expects a  pointer to uint8 type array along with the length. If you use the uint32 value directly, then you may get a compiler warning. Rather, you can store the value as a 4-byte array and then send the pointer to it. Or did you try typecast?

0 Likes