MQTT client for parsing GPB message packets
The intent of this sample set of codes is to guide would-be third-party developers that intend to consume SPoT/vSPoT data via Push API over MQTT with messages packed in Google Protobuf format.
- A Unix compatible Operating System (Debian Wheezy, CentOS 6.6 or Mac OSX 10.10)
- Download and install a compatible JDK version 1.7 (OpenJDK7, Oracle JDK 1.7.0u76, etc) (http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html) [works with JDK8 as well]
- Download and install gradle 2.3.x (https://gradle.org/)
- Download and install mosquitto 1.3.5 or 1.4.1 and above broker, client and requisite libraries (http://mosquitto.org/download/)
- Open firewall to ports 1883 and 8883
- Startup local mosquitto broker using the sample mosquitto bridge configuration file under mqtt_bridge_conf directory as a starting point (the TLS PSK connectivity is provided via MQTT bridge connection to reduce client code complexity)
- Test that you can locally subscribe to the mqtt-bridged TLS PSK connection to venue server using the
mosquitto_sub
utility- e.g.
mosquitto_sub -p 1883 -t "+/LOC/SPoT_GPB/#"
- e.g.
- You should see encoded messages streaming into your standard output terminal if the above mqtt bridge setup and topic subscription connection works
- Ensure that gradle 2.3 is installed and configured to work with JDK7 and that you have internet connectivity on the development machine
- Change directory into protobuf_bindings
- Issue
gradle
and observe that you receive no error messages in your standard output terminal - Compiled binding classes / source files for C++, java and python should now be generated and available under
- C++ : protobuf_bindings/build/generated/cpp
- java : protobuf_bindings/build/generated/java
- python: protobuf_bindings/build/generated/python
- Copy the requisite technology stack GPB binding classes / source files to your Push API client project source folder (under the intended directory structure)
- Ensure that gradle 2.3 is installed and configured to work with JDK7 and that you have internet connectivity on the development machine
- Change directory into sample_clients/pushapi_sample_java_client
- Issue
gradle
and observe that you receive no error messages in your standard output terminal - Compiled and executable code is available at sample_clients/pushapi_sample_java_client/build/install/pushapi_sample_java_client directory
- Ensure local mqtt bridged broker is setup and running (see above section "Pre-requisites to get started" - get the relevant venue server FQDN, PSK Identity and PSK to correctly bridge to the Push API MQTT publisher)
- Change directory to sample_clients/pushapi_sample_java_client/build/install/pushapi_sample_java_client
- Startup the client using
bin/pushapi_sample_java_client
- Observe the incoming MQTT decoded GPB messages received from the Push API MQTT publisher streaming in your standard output terminal
- Sample data stream:
org.fusesource.mqtt.client.Message@204f30ec locations { venue_id: "rksg-dev" mac: "E8802EF065CB" x: 0.0 y: 0.0 floor_number: 0 timestamp: 1429003890 } org.fusesource.mqtt.client.Message@e25b2fe locations { venue_id: "rksg-dev" mac: "FCE9982A9DB0" x: 1164.999 y: 693.9553 floor_number: 1 timestamp: 1429003890 }
- Sample data stream: