- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This might be more of a C programming question, but, in my app, when a device is scanned, there are several bytes in the CYBLE_GAPC_ADV_REPORT_T advReport->data (The advertisement packet) that need to be picked out in order to be directed to the next step. I know the simple way of just looking at each byte in the array, but I want put it all in a struct, and just the necessary bytes. For example, if a device includes the Service UUID (32-bit) + Service Data, which bytes are in advReport->data[16]-[22]: how can I put those in
struct scannedData {
uint32 serviceID;
uint8* serviceData;
}newScan;
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can extract the values inside the event CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT.
For e.g.,
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
advReport=*(CYBLE_GAPC_ADV_REPORT_T *)eventParam;
if(advReport.dataLen!=0)
{
Test_Data=advReport.data[16];
}
In your application, you can probably use a memcpy function - memcpy(&newScan.serviceID, &advReport.data[16], sizeof(uint32));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can extract the values inside the event CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT.
For e.g.,
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
advReport=*(CYBLE_GAPC_ADV_REPORT_T *)eventParam;
if(advReport.dataLen!=0)
{
Test_Data=advReport.data[16];
}
In your application, you can probably use a memcpy function - memcpy(&newScan.serviceID, &advReport.data[16], sizeof(uint32));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, using the memcpy function, using "&advReport.data[16], sizeof(uint32)" as one end of the comparison will pull the (4) 8-byte values from advReport.data?