Arduino HTTP REST API over BlueTooth with Android

Hello everyone!

I have been playing around with Arduino to build REST backends to support HTML user interfaces.

For the web server part I have been using the Webduino library. Webduino only works with Wiznet ethernet cards so I decided to abstract the transport stack behind an interface. This way it's possible to use for example serial connections and the CC3000 wifi chip with the library. The ability to use serial has many use cases. For example a serial to bluetooth adapter makes it possible to use the webserver over bluetooth with your Android mobile device and you can use XBees to make networks of servers and clients that communicate wiht each other wirelessly. The devices can also use multiple transport stacks simultaneously all with the same webserver code.

I have written some documentation that can be found from here:
https://www.cs.helsinki.fi/u/ljlukkar/wot/

Source code and some examples are here:

I currently don't have much time for this project but I'm happy to answer any questions.

Due to popular demand (none really) I made another example. A remote controller for the Blink server demonstrated in the first example.

Together with the first example they can be used for example like this

The source code for the Blink remote client is even simpler than the Blink server

#include <aJSON.h>
#include <ClientInterface.h>
#include <SerialClientAdapter.h>
#include <aJsonStore.h>
#include <HTTPStore.h>

// EthernetClient client;
// EthernetClientAdapter ethernetClientAdapter(client);
// byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// byte blinkServer[] = { 192, 168, 0, 11 };
// HTTPStore httpStorage(&ethernetClientAdapter);

SerialClientAdapter serialClientAdapter(&Serial);
HTTPStore httpStorage(&serialClientAdapter);
aJsonObject* ledModel  = aJson.parse("{\"id\":\"led\", \"on\":true}");

int buttonPin = 2;
bool lastState = 0;

void setup() {
  //Ethernet.begin(mac);
  //httpStorage.setServer(server, 80);
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);
}

void loop(){
  bool buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH && buttonState != lastState) {
    bool oldState = aJson.getObjectItem(ledModel, "on")->type;
    aJson.getObjectItem(ledModel, "on")->type = !oldState;
    httpStorage.saveModel("led", ledModel);
  }
  lastState = buttonState;
}

Everything needed for the setup including the HTML user interface is done with around 100 lines of C++ and JavaScript in total.