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

How BLE scan is done in the DFU (OTA) example?

Hi,

For nRF52840 BLE, in the DFU (OTA) example (buttonless OTA):

../nRF5_SDK_15.3.0_59ac345/examples/ble_peripheral/ble_app_buttonless_dfu

How scanning is done? Or where and which function initializes scan parameters?  Something similar to 

nrf_ble_scan_init_t init_scan;
m_scan.scan_params.window = m_iCommandScanWindow_MS; //MIN_SCAN_WINDOW;
m_scan.scan_params.interval = SCAN_INTERVAL;
m_scan.scan_params.timeout = 0;
m_scan.scan_params.scan_phys = 0 ;

err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);

Is there any way that I can modify the scanning interval and scanning timeout?

Thank You,

David Zhou

Parents
  • Hi David,

    Could you try to explain a bit more about why you are adding a scanner to this project? Is it to connect to other peripheral devices? The 'ble_app_buttonless_dfu' is a peripheral only example so it doesn't do scanning by default.

    Regards,

    Vidar

  • Vidar,

    It is under peripheral category or folder. I may miss something. If no scanning at all, how does it receive a new version of firmware data through Over-the-Air? And how does it know when to start firmware update when this example is buttonless DFU?

    What I am looking for is to optimize and reduce the power consumption. Even no scanning, the advertising interval is about 150ms, and I don't know where is the interval is set, and how to change it.

    Thank you,

    David 

  • Scanning is usually done by the DFU controller/master to find connectable advertising packets from the DFU target. You can adjust the APP_ADV_INTERVAL define to change the advertisement interval as you said. You may use our online power profiler (https://devzone.nordicsemi.com/nordic/power/) to estimate what impact it will have on power consumption.

    Regards,

    Vidar

  • Vidar,

    Thank you for your input.

    I have profiler and currently it measured at >500uA during advertising. It is too high for us. Could you please be more specific on the DFU controller/master? Is it in the SoftDevice or BLE library.  i guess if it is in the library, I would be able to make changes?

    Best Regards,

    David

  • Hi David,

    The DFU controller is the one that transfers the FW image to your DFU target device. It's usually a smartphone or PC.

    Please make sure you have disabled UART logging (NRF_LOG_BACKEND_UART_ENABLED=0) as that may explain the high base current.

    Best regards,

    Vidar

  • Vidar,

    Ok, DFU controller is at the host side. So I guess the CONNECT button on the DFU controller is connecting to the advertisement by the Device. BUT how and when the BLE device starts the firmware update process without scanning? I am still missing this point. Please explain. On the Host side (Andriod), clicks DFU icon, opens firmware .zip file, and reads firmware data into buffer, THEN it trys to connect DFU Target, (THIS SHALL BE THE DEVICE SIDE). It finds the services, ..., then JUMPing to DFU bootloader. SO where and how the DFU controller is connected to the DEVICE:

    Connected to DA:D5:58:B8:6F:C1

    If the device is not scanning? Sorry, I am missing something here.

    Regards,

    David

    //=============================================

    I 12:00:10.042 [DFU] Firmware file opened successfully
    V 12:00:10.042 [DFU] Connecting to DFU target...
    D 12:00:10.044 [DFU] gatt = device.connectGatt(autoConnect = false)
    I 12:00:10.051 [DFU] Connected to DA:D5:58:B8:6F:C1
    V 12:00:10.052 [DFU] Discovering services...
    D 12:00:10.052 [DFU] gatt.discoverServices()
    I 12:00:10.055 [DFU] Services discovered
    D 12:00:10.075 [DFU] wait(1000)
    I 12:00:10.631 Connection parameters updated (interval: 198.75ms, latency: 0, timeout: 4000ms)
    W 12:00:11.066 [DFU] Application with buttonless update found
    V 12:00:11.066 [DFU] Jumping to the DFU Bootloader...
    V 12:00:11.066 [DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
    D 12:00:11.066 [DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D 12:00:11.067 [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
    I 12:00:11.302 [DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 02-00
    V 12:00:11.302 [DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
    A 12:00:11.307 [DFU] Indications enabled
    D 12:00:11.309 [DFU] wait(1000)
    V 12:00:12.324 [DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50
    D 12:00:12.324 [DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
    A 12:00:12.693 [DFU] Enter bootloader sent (Op Code = 1)
    I 12:00:12.695 [DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 20-01-01
    A 12:00:12.695 [DFU] Response received (Op Code = 1, Status = 1)
    D 12:00:16.906 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0)
    E 12:00:16.906 Error 8 (0x8): GATT CONN TIMEOUT
    I 12:00:16.906 Disconnected

Reply
  • Vidar,

    Ok, DFU controller is at the host side. So I guess the CONNECT button on the DFU controller is connecting to the advertisement by the Device. BUT how and when the BLE device starts the firmware update process without scanning? I am still missing this point. Please explain. On the Host side (Andriod), clicks DFU icon, opens firmware .zip file, and reads firmware data into buffer, THEN it trys to connect DFU Target, (THIS SHALL BE THE DEVICE SIDE). It finds the services, ..., then JUMPing to DFU bootloader. SO where and how the DFU controller is connected to the DEVICE:

    Connected to DA:D5:58:B8:6F:C1

    If the device is not scanning? Sorry, I am missing something here.

    Regards,

    David

    //=============================================

    I 12:00:10.042 [DFU] Firmware file opened successfully
    V 12:00:10.042 [DFU] Connecting to DFU target...
    D 12:00:10.044 [DFU] gatt = device.connectGatt(autoConnect = false)
    I 12:00:10.051 [DFU] Connected to DA:D5:58:B8:6F:C1
    V 12:00:10.052 [DFU] Discovering services...
    D 12:00:10.052 [DFU] gatt.discoverServices()
    I 12:00:10.055 [DFU] Services discovered
    D 12:00:10.075 [DFU] wait(1000)
    I 12:00:10.631 Connection parameters updated (interval: 198.75ms, latency: 0, timeout: 4000ms)
    W 12:00:11.066 [DFU] Application with buttonless update found
    V 12:00:11.066 [DFU] Jumping to the DFU Bootloader...
    V 12:00:11.066 [DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
    D 12:00:11.066 [DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D 12:00:11.067 [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
    I 12:00:11.302 [DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 02-00
    V 12:00:11.302 [DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
    A 12:00:11.307 [DFU] Indications enabled
    D 12:00:11.309 [DFU] wait(1000)
    V 12:00:12.324 [DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50
    D 12:00:12.324 [DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
    A 12:00:12.693 [DFU] Enter bootloader sent (Op Code = 1)
    I 12:00:12.695 [DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 20-01-01
    A 12:00:12.695 [DFU] Response received (Op Code = 1, Status = 1)
    D 12:00:16.906 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0)
    E 12:00:16.906 Error 8 (0x8): GATT CONN TIMEOUT
    I 12:00:16.906 Disconnected

Children
No Data
Related