1

I'm sorry if this question sounds stupid, but I'm a complete noob to Web Development & Android Development. I'm working on a project that involves principles of IoT.

I have this Arduino that I want to communicate with using both the Internet & the Bluetooth (in case there's no Internet). I have designed a Web application that can communicate with the Arduino over the Internet & I have also made the Web Application an Android app using WebView.

The button on the Web application is configured to communicate with the Arduino only using Internet. So when that same Web page is viewed in Android via WebView, the button works only if there's Internet. However, I also want only the app to be able to communicate with the Arduino over Bluetooth when both the app & Arduino are connected via Bluetooth.

Is there any way I can configure the same button on Android app to work for Bluetooth without changing the configuration of the Button on the Web page??

Thanks for your time.

Auro
  • 1,578
  • 3
  • 31
  • 62
  • It may help to explicitly state how your Arduino is connecting via WiFi and Bluetooth (Internet is thing that each protocol can connect to). If you want to communicate between Arduino and Android over Bluetooth that is different than communicating over WiFi. Getting the WebView button to interact with Android Bluetooth would require anyone to know more about how you've written your WebView. – Morrison Chang Apr 09 '16 at 20:26

1 Answers1

0

There are some advancements on connecting web browsers to BLE, as seen here, but I believe for now the only consistent way is using native Android.

You can still use the webview for the UI, but the BLE handling will be native. To make your html button call a native function, you can intercept the clicks using one of the solutions available in Android WebView - Intercept clicks.

If you instead use cordova (that would let you use your html view), there are plugins that allow Bluetooth communication using JavaScript, like this one.

Community
  • 1
  • 1
Eduardo Bonet
  • 479
  • 6
  • 14