Check Bluetooth state

Check if Bluetooth adapter is enabled or not
#include <bluetooth.h>
#include <dlog.h> // for logging purposes

void
check_bluetooth_state() {
	bt_adapter_state_e bt_adapter;

	if(bt_initialize() == BT_ERROR_NONE) {

		if(bt_adapter_get_state(&bt_adapter) == BT_ERROR_NONE) {

			if(bt_adapter == BT_ADAPTER_ENABLED)
				LOGI("Bluetooth enabled");
			else
				LOGI("Bluetooth disabled");

		}
	}

	bt_deinitialize();
}

Responses

0 Replies