Reputation: 69
On Android NDK project we need to access bluetooth using a HAL interface. Our intention is to do something like this:
#include <hardware/hardware.h>
#include <hardware/bluetooth.h>
....
void load_Module(....)
{
hw_module_t* module;
hw_device_t* device;
bdt_log("Loading HAL lib + extensions");
err = hw_get_module(BT_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
if (err == 0){
err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
if (err == 0) {
bt_device = (bluetooth_device_t *)device;
sBtInterface = bt_device->get_bluetooth_interface();
}
}
}
Everybody seems to do the same (in google example code). There appears to be a problem when we try to compile:
#include <hardware/hardware.h> no such file
We properly added a permission to manifest and properly added libraries at Android.mk
Do we need to add something more? Is there a working project that I can refer to?
Upvotes: 3
Views: 2848
Reputation: 14009
You're trying to use libhardware on Android NDK project. libhardware is a part of Android framework, not a part of NDK.
https://github.com/android/platform_hardware_libhardware
So your project doesn't have true binary compatibility of Android if you can build your project with libhardware. It would work on some devices, some versions, but no guarantee.
From my experience, I believe you can build your code on AOSP. You need to modify Android.mk for AOSP not NDK.
Upvotes: 3