The TinkerForge Brick MQTT Proxy is handling MQTT messages from & to the Bricklets via the TinkerForge Brick Daemon. The application subscribes to TinkerForge Topics, as defined for the Bricklets . This is being handled within the B4J application by the jMQTT library. When a message from a Bricklet is received, the topic is determined first followed by parsing the message payload into a readable string, from which the value of the Bricklet is taken and displayed on the Webpage.
There are two B4J classes defined, the main project (in tfio16mqtt.b4j) and the Server Websocket Class.
The libraries used are jCore, JavaObject, jMQTT, jServer and Json. The application is accessed via Browser by calling the file Index.html located in the project Objects/www folder.
Build the application (B4J code as well as HTML,like the index.html file in the objects/www folder).
When using the B4J Bridge for test purposes, the content of the objects/www folder must be copied to the Raspberry Pi /home/pi/b4j/tempjars/www folder.
Start the B4J Bridge on the Raspberry Pi ($cd /home/pi/b4j, $sudo java -jar b4j-bridge.jar) and connect from the B4J IDE (Tools > B4J Bridge > Connect > Raspberry Pi IP Address)
Run the application from the B4J IDE (press F5).
To access the application from the Webbrowser, use as IP address localhost with port 51042 (e.g. http://localhost:51042). The file index.html is loaded. To start:
To install the experiment on the Raspberry Pi:
Notes: Do not forget to copy the content of the objects/www folder every time a change is made, else still the old version is used.