It's more convenient to control three LEDs from the Android app. It's fine if you use a browser on Android and navigate to the RESTful server on Raspberry Pi. We call our RESTful from the Android app. In this section, we will build a PhoneGap app for the Android target and control the three LEDs. We use the previous program, the ledrest.js
file, as a RESTful server, which controls LEDs on Raspberry Pi.
First, we create a PhoneGap project named leds-android
:
$ phonegap create leds-android $ cd /leds-android $ phonegap build android --verbose
Try to run the program on the Android emulator for testing purposes:
$ phonegap run android --emulator --verbose
If the program runs well, we continue to modify our program. To communicate between the PhoneGap Android and RESTful server, we use jQuery, the https://jquery.com
. Place jquery-*.*.*.min.js
file into the <project_root>/www/js
folder. The next step is to modify the index.html
and...