This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Android NDK Support?

I need to write some code at the NDK level to access some Bluetooth features that aren't exposed at the Java level. For example, I want to have a 2nd bluetooth adapter on my Android device. I looked at the SDK download and the Github Android samples and there isn't anything obvious there to help. Is there any C code or SDK/API docs that can be used? I looked at getting the card and SDK from a supplier but they didn't know if there would be any Android driver support either, and suggested that I come here for guidance. Any ideas would be appreciated. Right now, I just building my application using generic code that accesses the bluedroid headers in the NDK, and it's very painful! Thanks.

Parents
  • You have two issues here that involve a bit of misunderstanding. One is, BLE central and BLE peripheral both use the same mechanism to ping for RSSI. If you blindly and naively attempt RSSI triangulation, you absolutely can do it with one BLE device in your Android hardware and several peripheral devices used for triangulation all simultaneously connected to the one BLE device on the Android hardware. Your embedded nordic chip BLE can only handle one connection at a time, this is not a limitation of the expensive dual WiFi/BLE chips. 3 to 5 device connections should be fine. CSR BLE 101x allows you to broadcast / scan even while already being connected, which allows all your peripherals to be able to ping each other for RSSI while being connected to the Android device and not to each other, which is another reason why you don't need multiple BLE adapters in one Android device. I assume Nordic BLE chip also lets you do this.

    Second issue is you can thunk into Java from C++, it goes both ways, not a big deal. Use the REGULAR Android BLE Java library in your C++ application, thunk into it. There is no BLE API in the NDK and whatever you think you can use in lieu of it will be laughable at best. I have successfully used the Android BLE Java library from C++ in my app. It is a pain but better than the alternative.

Reply
  • You have two issues here that involve a bit of misunderstanding. One is, BLE central and BLE peripheral both use the same mechanism to ping for RSSI. If you blindly and naively attempt RSSI triangulation, you absolutely can do it with one BLE device in your Android hardware and several peripheral devices used for triangulation all simultaneously connected to the one BLE device on the Android hardware. Your embedded nordic chip BLE can only handle one connection at a time, this is not a limitation of the expensive dual WiFi/BLE chips. 3 to 5 device connections should be fine. CSR BLE 101x allows you to broadcast / scan even while already being connected, which allows all your peripherals to be able to ping each other for RSSI while being connected to the Android device and not to each other, which is another reason why you don't need multiple BLE adapters in one Android device. I assume Nordic BLE chip also lets you do this.

    Second issue is you can thunk into Java from C++, it goes both ways, not a big deal. Use the REGULAR Android BLE Java library in your C++ application, thunk into it. There is no BLE API in the NDK and whatever you think you can use in lieu of it will be laughable at best. I have successfully used the Android BLE Java library from C++ in my app. It is a pain but better than the alternative.

Children
No Data
Related