(Take care, in future version '1.0.0-SNAPSHOT' will be another number!)
To use this library you need to:
- Compile the platform, this generates en your local Maven Repository: $M2_REPO\com\minsait\onesait\platform\onesaitplatform-comms-protocol\1.0.0-SNAPSHOT\onesaitplatform-comms-protocol-1.0.0-SNAPSHOT.jar
- Compile the client library, this generates $M2_REPO\com\minsait\onesait\platform\onesaitplatform-java-client\1.0.0-SNAPSHOT\onesaitplatform-java-client-1.0.0-SNAPSHOT.jar and $M2_REPO\com\minsait\onesait\platform\onesaitplatform-java-client\1.0.0-SNAPSHOT\onesaitplatform-java-client-1.0.0-SNAPSHOT-spring-boot.jar
The Client Library packaged with suffix can be executed stand-alone.
- Go to $M2_REPO\com\minsait\onesait\platform\onesaitplatform-java-client\1.0.0-SNAPSHOT\
- Execute java -jar onesaitplatform-java-client-1.0.0-SNAPSHOT-spring-boot.jar
- This shows a console app that guides you in order to execute a test of the platform

If you want to use this client-library:
- Add following dependency to your project:
<dependency>
<groupId>com.minsait.onesait.platform</groupId>
<artifactId>onesaitplatform-java-client</artifactId>
<version>${onesaitplatform.version}</version>
</dependency>
- Go to package ** com.minsait.onesait.platform.client.examples** and review examples:
- RestAppExample: example of client connecting with REST protocol
- MQTTApplicationExample: example communicating with MQTT protocol
- Client4IoTBrokerConsole: console example shown in previous step
- BinaryRepoAppExample: example for manage binaries with the IoTBroker
MQTTClient API allows your application to connect and send data to the IoT Broker, using MQTT as the transport protocol.
This client allows you to configure MQTT over SSL. To create a secure connection, follow these steps:
-
Create a MQTTSecureConfiguration object specifying the path to your Key Store (.jks), and its password. If one of them is not specified, then default Key Store and password will be used.
-
Create a MQTTClient with the Broker URL and the MQTTSecureConfiguration object.
If you don't want to use a secure connection, you may use standard MQTT protocol:
To connect client to Broker, you need to call method "connect()" with aguments: token, device identification, device instance identification, and timeout for waiting broker response (in seconds). example: client.connect("token", "Device", "Device:mqtt", 5);
You can publish messages through method "publish()", arguments needed: ontology identification name, ontology instance as string (must be json format!), and timeout in seconds.
You can subscribe to an ontology through method "subscribe()", by specifying the Query (filter), the ontology identification, the type of query (Native or SQL), timeout in seconds for waiting subscription ACK response, and lastly, a handler/listener is needed for handling incoming messages from the subscription.
By calling this method you get a String with the subscriptionId, needed to unsubscribe.
You can unsubscribe with method "unsubscribe()", with the subscriptionId obtained before.
To terminate the connection, call method "disconnect()".
A jar is provided to test this client. To use it you need to provide 3 arguments:
- Broker URL (Mandatory)
- Path to key file ".jks" (Optional for MQTTS)
- Password for key file (Optional for MQTTS)
A .jks file is provided in the repository : 'clientdevelkeystore.jks', with password 'changeIt!' Example: java -jar java-client.jar "ssl://localhost:8883" "S:\examples\java-clients\clientdevelkeystore.jks" "changeIt!"




