- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
I have a problem.How to send a 16 bytes notification?
now,my code only can send a 4-bytes notification.
Is there any error with my code?
My code and GATT definition are as below:
#define OEM_HANDLE_SERV_BATT_MONITOR 0x0500
#define OEM_UUID_SERV_BATT_MONITOR 0x2B, 0x6B, 0xFA, 0xD1, 0x7C, 0x30, 0x2D, 0x94, 0x62, 0x4C, 0x84, 0x38, 0xCE, 0xB7, 0x87, 0x00
// 0087B7CE-3884-4C62-942D-307CD1FA6B2B
#define OEM_HANDLE_CHAR_BATT_MONITOR 0x0501
#define OEM_HANDLE_VALUE_BATT_MONITOR 0x0502
#define OEM_UUID_CHAR_SERV_BATT_MONITOR 0x03, 0xD8, 0xD7, 0x92, 0x4E, 0x58, 0xF1, 0x87, 0x56, 0x4C, 0x28, 0x35, 0x7A, 0xC4, 0xF9, 0x4B
// 4BF9C47A-3528-4C56-87F1-584E92D7D803
//Battery Monitor Service
PRIMARY_SERVICE_UUID128 (OEM_HANDLE_SERV_BATT_MONITOR, OEM_UUID_SERV_BATT_MONITOR),
// Characteristic: battery monitoring
CHARACTERISTIC_UUID128(OEM_HANDLE_CHAR_BATT_MONITOR,
OEM_HANDLE_VALUE_BATT_MONITOR,
OEM_UUID_CHAR_SERV_BATT_MONITOR,
LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY,
LEGATTDB_PERM_READABLE ,8),
0x00, 0x00, 0x00,0x00, 0x00, 0x00,0x00, 0x00,
if (bleprofile_ReadHandle (OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu) == 0)
{
//ble_trace0("read batt handle is true \n");
// save to GATT DB for sync with GATT read request
for(i=0;i<EC_REPORT_SIZE;i++)
{
db_pdu.pdu = ec_report;
}
db_pdu.len=8;
//EC_REPORT_SIZE
if(bleprofile_WriteHandle (OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu)==0)
ble_trace1("read batt handle is true %x\n",db_pdu.pdu [0]);
bleprofile_sendNotification (OEM_HANDLE_VALUE_BATT_MONITOR,db_pdu.pdu, db_pdu.len);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The biggest problem I see is that your GATT database is sized to 8 bytes. This is the final digit of the vendor-specific characteristic. But this doesn't explain why you can't write past 4 bytes.
A couple things to note. Be sure that your handles are all incrementing. They are in this example, but make sure that they increment with respect to the rest of your GATT database as well.
Assuming you're using LightBlue or a similar app, try forgetting the device in your phone's settings. This can solve strange behavior having to do with the GATT database.
Finally, try executing your notify loop in the easiest way possible:
void notify_function (void) {
BLEPROFILE_DB_PDU db_pdu;
bleprofile_ReadHandle(OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu);
for(i=0; i<16; i++){
db_pdu.pdu = ec_report;
}
bleprofile_WriteHandle(OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu);
bleprofile_sendNotification(OEM_HANDLE_VALUE_BATT_MONITOR, (UINT8 *)db_pdu.pdu, db_pdu.len);
}
If the code above doesn't work, the problem likely lies in your GATT database. Refer to How to Write WICED Smart Applications for further reading on the GATT DB.
Jacob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The biggest problem I see is that your GATT database is sized to 8 bytes. This is the final digit of the vendor-specific characteristic. But this doesn't explain why you can't write past 4 bytes.
A couple things to note. Be sure that your handles are all incrementing. They are in this example, but make sure that they increment with respect to the rest of your GATT database as well.
Assuming you're using LightBlue or a similar app, try forgetting the device in your phone's settings. This can solve strange behavior having to do with the GATT database.
Finally, try executing your notify loop in the easiest way possible:
void notify_function (void) {
BLEPROFILE_DB_PDU db_pdu;
bleprofile_ReadHandle(OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu);
for(i=0; i<16; i++){
db_pdu.pdu = ec_report;
}
bleprofile_WriteHandle(OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu);
bleprofile_sendNotification(OEM_HANDLE_VALUE_BATT_MONITOR, (UINT8 *)db_pdu.pdu, db_pdu.len);
}
If the code above doesn't work, the problem likely lies in your GATT database. Refer to How to Write WICED Smart Applications for further reading on the GATT DB.
Jacob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
any updates?