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.

CC2652R: ble scanning crashes after receiving some advertisements

Part Number: CC2652R

void KB_App_enableScan(){
int status;
uint8_t temp8;
uint16_t temp16;


// Register callback to process Scanner events
status = GapScan_registerCb(KB_gap_ScanCallback, NULL);

// Set Scanner Event Mask
status = GapScan_setEventMask(GAP_EVT_SCAN_ENABLED | GAP_EVT_SCAN_DISABLED |
GAP_EVT_ADV_REPORT);

// Set Scan PHY parameters
status = GapScan_setPhyParams(DEFAULT_SCAN_PHY, DEFAULT_SCAN_TYPE,
DEFAULT_SCAN_INTERVAL, DEFAULT_SCAN_WINDOW);

// Set Advertising report fields to keep
temp16 = ADV_RPT_FIELDS;
status = GapScan_setParam(SCAN_PARAM_RPT_FIELDS, &temp16);
// Set Scanning Primary PHY
temp8 = DEFAULT_SCAN_PHY;
status = GapScan_setParam(SCAN_PARAM_PRIM_PHYS, &temp8);
// Set LL Duplicate Filter
temp8 = SCANNER_DUPLICATE_FILTER;
status = GapScan_setParam(SCAN_PARAM_FLT_DUP, &temp8);

// Set PDU type filter -
// Only 'Connectable' and 'Complete' packets are desired.
// It doesn't matter if received packets are
// whether Scannable or Non-Scannable, whether Directed or Undirected,
// whether Scan_Rsp's or Advertisements, and whether Legacy or Extended.
temp16 = SCAN_FLT_PDU_NONCONNECTABLE_ONLY | SCAN_FLT_PDU_EXTENDED_ONLY | SCAN_FLT_PDU_COMPLETE_ONLY;
status = GapScan_setParam(SCAN_PARAM_FLT_PDU_TYPE, &temp16);
status = GapScan_enable(_KB_GAP_PERIOD, DEFAULT_SCAN_DURATION, 0);
}
this is my gap scan enable mode and i'm using observer+peripheral mode 
while scanning for advertisements after receiving 70 advertisement my code crashes
kb_app.c
the above is the complete code where the scan is present

the above image is the observer configuration can i know the exact reason why after some 70 scanning data receiving crash the code
i'm also freeing the scanning data on receiving

edit:
the multi role example i tried with making pheripheral and obeserver , but it receive only 205 advertisement and didn't crash the code still the gapscan enable event is calling but it is not receiving any adv reports

  • Hi,

    Thank you for reaching out.

    I am thinking about a memory leak issue as you mentioned the issue reproduce after a fix number of reports. In order to check this theory, I would like you to check on the heap usage as described in the debugging guide.

    In addition, could you please provide the code executed in the KB_gap_ScanCallback() and the code it eventually triggers?

    I hope this will help,

    Best regards,

  • complete code in kb_app.c i added file in above

  • Hi,

    Thank you for telling me - I missed the attached file in the first place.

    Based on my review of your code, it seems the advertisement report payload data is not freed - which could be explaining the issue observed.

    In order to free-up the advertisement report payload data, I would recommend to add the code below under the "_KB_ADV_REPORT_EVT" case ("SC_EVT_ADV_REPORT" case for the unmodified simple_central example):

    Fullscreen
    1
    2
    3
    4
    5
    6
    // Free report payload data
    if (pAdvRpt->pData != NULL)
    {
    ICall_free(pAdvRpt->pData);
    }
    break;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I hope this will help,

    Best regards,

  • solved the issue, may i know the easy way to learn debugging , as i am new person to ti development it's very hard to under the debug document given above

  • Hi,

    Great to hear you got the issue fixed!

    The debugging guide I have provided presents the main approaches possible. Personally, I really like the ROV and all the debug possibilities offered by CCS.

    In addition, please take a look at TI Developer Zone https://dev.ti.com/

    Best regards,