This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-CC2652RB: Trying to read extended advertisement data from bluetooth scan

Part Number: LP-CC2652RB

I have a device that is constantly broadcasting both bluetooth coded phy (125 kbps) extended advertisements and bluetooth 4 advertisements, that I am sure is functional. I am trying to program the LP-CC2652RB to scan for the coded phy extended advertisements broadcast by this device, and print out the binary bits of the extended advertising data through the serial terminal. However, the behavior is not as expected.

I am starting off with the simple_central sample code made for the LP-CC2652RB. I added the the following code to be able to print out the bits of the extended advertising data: #define BIT_TO_ARRAY_SIZE and the function get_bit help print out the individual bits of the advertising data, and I inserted the rest of the code under case SC_EVT_ADV_REPORT, to store the advertising data in a char array and print to the serial terminal:

/*
 * Helper function and definition for SimpleCentral_processAppMsg that helps print the advertising data 1 bit at a time
 *
 * source: https://www.sanfoundry.com/c-program-implement-bit-array/
 */
#define BIT_TO_ARRAY_SIZE(x) (x/8+(!!(x%8)))   // convert from number of bits to number of chars
char get_bit(char *array, int index) {
    return 1 & (array[index / 8] >> (index % 8));
}

// TEST PRINTING ADVERTISING DATA
uint8_t *adv_data_pointer = pAdvRpt->pData;
uint16_t adv_len = pAdvRpt->dataLen;  // in bits
char adv_data[BIT_TO_ARRAY_SIZE(adv_len)];       // initialize char array to hold raw bits of advertising data
// THIS LINE BELOW IS CAUSING ERROR
pAdvRpt->pData = &adv_data[0];
Display_printf(dispHandle, SC_ROW_AC+1, 0, "ADVERTISING DATA LENGTH: %i", adv_len);
for(int loop = 0; loop < adv_len; loop++) {
    Display_printf(dispHandle, SC_ROW_AC+3+loop, 0, "ADVERTISING DATA %d: %d", loop, get_bit(adv_data, loop));  // print hex characters
}
// Delays n*10 microseconds
Task_sleep(100000*10/Clock_tickPeriod);

When I run the code, the serial terminal allows me to select a scanning PHY. if I select the scanning PHY to be coded, it never detects any devices despite the broadcasting device being right next to it. If I select the scanning PHY to be 1 Mbps, it is able to detect devices, but the "ADVERTISING DATA LENGTH" that is printed is always quite small (between 0 and 31, from what I have seen so far), and the individual bits printed in the serial terminal seem to be nonsense; the exact same bits get printed for different detected devices even though the advertising data length changes. Oftentimes, the last 10-20 bits that are printed out are also 0.

Here is some video footage of the printed data on the serial terminal: 

Another issue with the code is that, after detecting 2 or 3 devices, the program always raises an error and the serial terminal freezes. I'm not sure why my code would cause that.

I've also attached my syscfg file if it is helpful:

I also want to ask, what are the units of GapScan_Evt_AdvRpt_t Struct -> dataLen? (i.e. bits, bytes?)

Also, here is the exact bit-encoding of the primary and extended advertisement frames that I am trying to scan for:

/resized-image/__size/320x240/__key/communityserver-discussions-components-files/538/pastedimage1683065836039v2.png

/resized-image/__size/320x240/__key/communityserver-discussions-components-files/538/pastedimage1683065911097v3.png

Does anyone have suggestions about how to write code that will perform the functionality that I want? 

Would be really great if I could get some help on this fast. Thank you.