Filtering scanned data

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

cross mob
Anonymous
Not applicable

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;

0 Likes
1 Solution
Anonymous
Not applicable

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));       

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

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));       

0 Likes
Anonymous
Not applicable

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?

0 Likes