I am looking for a way to make a periodic bluetooth request from my Android smartphone (HTC Desire with Android 4.0.1). The device is rooted, and it is a regular Rom, set so that I have full privileges. I have already written shellscript that uses hcitool, hciconfig and hcidump to execute the request. While this works, but for me it slows down a bit. I suppose due to my dirty workaround of using an android application to execute shellscript from linux. Although I am having problems killing executed processes through my application.
So, I would like to find a way to learn BT Devices from the Android API. I found out that there is no possibility right now, but I read about the Bluez API, which may possibly correspond to my requests. Does anyone have any links, tips or tips for me?
I did not find anything useful: /
Thanks in advance.
Edit (2012-09-28):
Well, I think that is now a little closer to the solution. I downloaded the source of the blueZ library from: bluez.org
Then I put the important files (hci.h, bluetooth.h, hcilib.h and their source files) into the jni folder of my Android project and compiled them into my shared library. I wrote JNI Wrapper around a function
hci_inquiry(int dev_id, int len, int nrsp, const uint8_t *lap,inquiry_info **ii, long flags)
and after consulting this read my book. Everything is fine while here.
But when I run the request, the function
dev_id = hci_get_route(NULL);
always returns -1, and I cannot continue.
Bluetooth , root- . : (
, , ? BlueZ HCI Android?
, JBlueZ ?
:
inquiry_info *ii = NULL;
int max_rsp, num_rsp;
int dev_id, sock, len, flags;
int i;
char addr[19] = { 0 };
char name[248] = { 0 };
dev_id = hci_get_route(NULL);
if (dev_id < 0 ) {
LOGI("ERROR ON finding Device ID");
return;
}
sock = hci_open_dev( dev_id );
if (sock < 0) {
LOGI("ERROR ON opening socket");
return;
}
len = 8;
max_rsp = 255;
flags = IREQ_CACHE_FLUSH;
ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info));
num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
//
.