- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am using PSoC4 Ble as a server to send temperature data to client. I have created custom profile in which one service has been created and characteristic for the temperature. I have used Cyble_GattsWriteAttributeValue() to write the values to the gatt database. But it's not working. I have tested this on Windows CySmart application. I could connect to the psoc module, but i was unable to discover the attributes .
Can anyone please suggest any corrections to be made in this code?
Thank you in advance.
-Neeraj
void Stack_Handler(uint32 eventCode, void *event_Param)
{
switch(eventCode)
{
case CYBLE_EVT_STACK_ON:
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
break;
case CYBLE_EVT_GATT_CONNECT_IND:
cyBle_connHandle = *(CYBLE_CONN_HANDLE_T *)event_Param ;
break;
}
}
void updateGattData(uint8 temp, uint16 attrH)
{
CYBLE_GATT_HANDLE_VALUE_PAIR_T *envdata;
CYBLE_GATT_ERR_CODE_T result;
envdata->attrHandle = attrH;
envdata->value.val = &temp;
envdata->value.len= 2;
envdata->value.actualLen=2;
result = CyBle_GattsWriteAttributeValue(envdata,0,&cyBle_connHandle,CYBLE_GATT_DB_LOCALLY_INITIATED);
}
int main()
{
int16 temp1, temp2,temp1_mV,temp2_mV, hum, hum_mV;
uint8 temperature;
CyGlobalIntEnable; /* Enable global interrupts. */
CyBle_Start(Stack_Handler);
ADC_SAR_Seq_1_Start();
ADC_SAR_Seq_1_StartConvert();
for(;;)
{
if( ADC_SAR_Seq_1_IsEndConversion(ADC_SAR_Seq_1_WAIT_FOR_RESULT))
{
temp1 =ADC_SAR_Seq_1_GetResult16(0);
temp2 =ADC_SAR_Seq_1_GetResult16(1);
hum = ADC_SAR_Seq_1_GetResult16(2);
temp1_mV = ADC_SAR_Seq_1_CountsTo_mVolts(0,temp1);
temp2_mV = ADC_SAR_Seq_1_CountsTo_mVolts(1,temp2);
hum_mV = ADC_SAR_Seq_1_CountsTo_mVolts(2,hum);
temperature= (temp1_mV - temp2_mV);
}
CyBle_ProcessEvents();
CyDelay(500);
updateGattData(temperature,CYBLE_ENVSENSING_TEMPERATURE_CHAR_HANDLE);
}
}
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to write the attribute - I think the notification just tells the GATT client that a new value is available, without sending the value with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you cannot discover the attributes, either you have set up the BLE profile the wrong way, or your client is doing something wrong. Are you using CySmart as GATT client?
(Note that writing to the attribute doesn't push the changes to the client automatically)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay.. Thank you.
As per your advice, i tried to push notifications to the client using Cyble_GattsNotification(). It worked properly. I can discover all the attributes and read the characteristics value on Cysmart windows application.
But writing to the attributes is not working . I think sending the data using notifications would be sufficient . Is it required to write the data values to the gatt database?
I will try to combine both these things and check if it works or not.
Thank you very much.
-Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to write the attribute - I think the notification just tells the GATT client that a new value is available, without sending the value with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot.
I have completed writing the attribute values into the gatt database and notifying the client with the notifications.
Both these things are working satisfactorily.
Thanks for your help.
-Neeraj
- 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
I created a custom profile which contained my custom service along with the GAP and GATT service (Total 3 services). I created two custom characteristics : one for temperature and other for the humidity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Am I supposed to use a UART in schematic to send data to cysmart from psoc board? It would be helpful if you could forward me the project.
Thank You