Initialize the device

Before calling any other Bluetooth functions in btdevice.h, you must initialize the Bluetooth device.

Initialize the device by calling bt_device_init(). This function takes one argument for a callback, which is called when Bluetooth events are sent to your application.
typedef void(* bt_device_cb)(const int event, 
                             const char *bt_addr, 
                             const char *event_data);  
            
When defining your callback, check for all Bluetooth events of interest to make sure that your operations are successful. All Bluetooth events start with BT_EVT_, and are defined in btdevice.h.
The following code snippet shows how to initialize the Bluetooth device:
void myCallback(const int event,      // the Bluetooth event
                const char *bt_addr,  // the Bluetooth MAC address
                const char *event_data) // the event data
{
    // Perform Bluetooth event handling
    // ...
 
}

bt_device_init(myCallback);