5 years, 3 months ago.

Why do I get "Use of deprecated scan API with up to date API" error

I am using the mBED 5.13.1 on both the peripheral and the central devices and I get the error below when I try to call stopAdvertisiing()

++ MbedOS Error Info ++ Error Status: 0x80180147 Code: 327 Module: 24 Error Message: Use of deprecated scan API with up to date API Location: 0x101E3 Error Value: 0x0 Current Thread: main Id: 0x20003968 Entry: 0x636E7 StackSize: 0x1000 StackMem: 0x200077D8 SP: 0x20008180 For more info, visit: https://mbed.com/s/error?error=0x80180147 MbedOS Error Info

1 Answer

5 years, 2 months ago.

Hi John,

Referring to the doxy documentation here about disconnect(),

https://os.mbed.com/docs/mbed-os/v5.13/mbed-os-api-doxy/class_gap.html#af6f3bf5b22b33d9f3c8dd198618c6b00

It says "Deprecated since addition of extended advertising support. Use disconnect(connection_handle_t, local_disconnection_reason_t) instead", so you need to call it with different parameters. You may need to add below code snippets.

void onConnectionComplete(const ble::ConnectionCompleteEvent &event) {
        _connection_handle = event.getConnectionHandle();
    }

ble_error_t error = _ble.gap().disconnect( _connection_handle, 
        ble::local_disconnection_reason_t::USER_TERMINATION );

ble::connection_handle_t _connection_handle;

Let me know if you need further help.

Thanks, Desmond