This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Address Filter not working

I have an NRF52 DK, and an IM21 door sensor that advertises events. I am trying to pick up these events with the nRF52DK in the most robust way possible. I have used the scanning library to implement an address filter to identify the IM21 events by the IM21 adress. My implementation is screenshotted below and I have verified that the address and address type are correct.

This code is in the scan_init() function:

I am verfying that the sensor is found through this print statement below, which isn't printing:

I also picked up the packets that are being advertised with the NRF Sniffer. The packet advertised is highlighted in this image below:

I welcome any ideas regarding where I may have gone wrong or missed something of importance.

Thank you very much, 

Maria

  • Hi Maria

    Due to the summer vacation period here in Norway we are short on staff and delayed replies must be expected. I'm sorry for any inconvenience this might cause.

    First off, have you double checked that the address you've set in the scan filter and on the advertising device is the same? Can you provide a snippet of code showing the main() loop of your application. Are you sure it starts scanning at all?

    Best regards,

    Simon

  • To answer your two questions: I am sure the address set matches the advertising device and I am not sure it starts scanning at all. 

    In the time since posting this inquiry I have done some debugging, made some modifications, and the application is currently crashing at nrf_ble_scan_start(&m_scan),  which is returning 9. I do not know what an error code of 9 means. 

    I will re attach all the screenshots of my code in case I modified code that was screenshotted above. All these modifications were made to the ble_central/ble_app_uart_c example in the SDK version 17 with soft device 132.

    Declaration of advertising device address:

    Definition of m_scan_param for advanced initialization:

    My scan_init() function where I initialize the scanning module and set and enable the address filter. I have connection set to false as the advertising device is a beacon:

    My scan_start() function. The application is crashing at line 153 with the app checking the ret variable, which I printed and learned that it is 9. I do not know what 9 signifies.

    Here is my main function as you requested:

    Do you know when the engineers will be back from Vacation? I have been having issues with this module for two months now and it is due in two weeks. Thank you for helping me Slight smile

    Best,

    Maria

  • Hi Maria

    Thank you.

    nrf_ble_scan_start() returning error 9 means that there is an invalid length somewhere in this function. Likely returned from the sd_ble_gap_scan_start() function which would indicate that the provided buffer length is invalid. What have you set the buffer length to? The scan buffer length  for an advertising set should be 31 bytes. If you set the scan param extended bit to 1, a scan buffer length of 255 is allowed.

    Best regards,

    Simon

  • Hello,

    Thank you - I changed the extended bit to false and now it is running with no errors! However, the scanning module is still not recognizing my iBeacon.

    I made some changes to the scan_evt_handler() function and it now looks like this:

    In summary, if it sees an advertisement with an address that does not match IM21_ADDRESS, it prints the address it saw. If it sees an advertisement that matches the IM21_ADDRESS, it prints a "Door Sensor Found" message.  As the door sensor iBeacon advertises, I see it's address being printed, meaning that the scanning module sees the advertisement, but it appears that the address doesn't match.

    This is what is printed (the correct first three bytes of the address): 6bc651 

    This is what the address is set as:

    I don't know what is going on - is the peer address different from the direct address? How can I get the address filter to recognize the address? I checked to make sure that the address type was correct.

    Best,

    Maria

  • Can you confirm whether or not the beacon actually advertises the full address, and not just these three bytes? It could be that the iBeacon tries to advertise more than 31 bytes, and therefore some of these address bytes are cut out of the advertisements, causing only 3 of them to be advertised, and would explain why the scanner can't confirm the address.

    Best regards,

    Simon

Related