AWS IoT Core Example

Demonstration of MQTT Publish / Subscribe functionalities for AWS IoT Core.
EXAMPLE for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: SDK
Last updated:
29 October 2018
+
# Overview

Demonstration of MQTT Publish / Subscribe functionalities for AWS IoT.

It contains two projects :
- com.microej.demo.aws.iot :
	The demonstration code is located here, the entry point class is `com.microej.demo.aws.iot.Main`.
	It contains the launcher for the embedded mode (currently working on Wi-Fi boards).
- com.microej.demo.aws.iot-sim :
	Mock and launcher for the demonstration to work correctly in Simulator mode.

This example has been tested on Murata 1LD eval board with a MurataType1LD 1.0.0 MicroEJ platform.
	
# Requirements

- Install the MicroEJ SDK which can be found [here](http://developer.microej.com/getting-started-sdk.html) - section 1
- Add a platform with NET-1.1, SSL-2.1 and Wi-Fi support ECOM-WIFI-2.1

# Setup

You should already have cloned this repository in `[git.repo.dir]`.

First start the MicroEJ SDK on a new workspace `[workspace.dir]`.

Importing the Git repository in a MicroEJ SDK:

 - once started, import the Eclipse projects: `File` > `Import` > in `Projects from Git`, type and select `Existing local repository` > `Next` > `Add` > `Browse`
 and select the `[git.repo.dir]`> `Finish` > select your repo `Next` > `Import existing Eclipse projects` > import all the projects.
 - enable the Ivy Resolving in workspace `Window` > `Preferences` > `Ivy` > `Classpath Container` > check `Resolve dependencies in workspace`
 - after an Ivy Resolving, may take a while, the projects should compile (no red markers on the projects)

# Launching the AWS IoT Demo

## Getting ready with AWS IoT
- create AWS account through [AWS console](https://aws.amazon.com/console/)
- go to `IoT Core`
- go to `Secure` > `Policies`
- create a policy (it describes what your device will be able to do like subscribing and publishing)
- name it and configure it like this (copy/paste is available by clicking on `Advanced mode` of the `Add statements` section) :
	```
	{
	 "Version": "2012-10-17",
     "Statement": [
       {
         "Action": [
           "iot:Publish",
           "iot:Subscribe",
           "iot:Connect",
           "iot:Receive"
         ],
         "Effect": "Allow",
         "Resource": [
           "*"
         ]
       }
     ]
   }
   ```
- click on create
- go to `Manage`
- click on `Create`
- click on `Create a single thing`
- name your thing and click on `Next`
- choose the `One-click certificate creation (recommended)` option by clicking on `Create certificate`
- on the `Certificate created` page, download every certificates and keys
- click on the `Activate` button to enable the certificate authentication of your thing
- click on `Attach a policy`
- select the previously created policy

If you have any trouble, the AWS IoT full documentation can be found [here](https://docs.aws.amazon.com/iot/latest/developerguide/iot-console-signin.html)
 
## Getting ready with the certificates
- transform the private key like this using [OpenSSL](https://www.openssl.org/source/):
	`openssl.exe pkcs8 -inform PEM -in myprivate.pem.key -topk8 -outform DER -out myprivate.der -v1 PBE-SHA1-3DES -passout pass:awsdemo`
- add your private key and certificate in the folder
`[worspace.dir]/com.microej.demo.aws.iot/src/main/resources/certificates/device`
- add the paths to your private key and certificate in `[worspace.dir]/com.microej.demo.aws.iot/src/main/resources/aws.iot.demo.resources.list`
	```
	certificates/device/myprivate.der
	certificates/device/mycertificate.pem.crt
	```
- modify the properties file that will be used to initialize the SSL context, located at `[worspace.dir]/com.microej.demo.aws.iot/src/main/resources/certificates/aws.iot.demo.device.certificates.properties`
	```
	# the path of the device certificate
	certificate.file.name=/certificates/device/mycertificate.pem.crt
	# the path of the device private key (encoded with the previous openssl command)
	private.key.file.name=/certificates/device/myprivate.der
	# the password used in the previous openssl command (the part afer pass:) -passout pass:awsdemo
	keystore.password=awsdemo
	```
	
## Getting ready with the application configuration
- in order to find your broker host, go to your AWS IoT Console, click on `Manage` > `Things` and select your Thing previously created. Then click on `Interact` and the broker host is shown under the HTTPS section and should look like this : `{myowndomainid}.amazonaws.com`
- your host `{myowndomainid}.amazonaws.com` may have `-ats` in its path, if so, remove it. `xxxxxxxxxx-ats.iot.yyyyyyyyy.amazonaws.com` => `xxxxxxxxxx.iot.yyyyyyyyy.amazonaws.com`.
- configure your information in `[worspace.dir]/com.microej.demo.aws.iot/src/main/java/com/microej/demo/aws/iot/Config.java` :
	- your MQTT AWS broker host and port :
		```
		public static final String AWS_BROKER_HOST = "myowndomainid.amazonaws.com";
		public static final int AWS_BROKER_PORT = 8883;
		```
	- your AWS thing id :
		```
		public static final String AWS_THING_ID = "myThing";
		```
	- your Wi-Fi credentials :
		```
		public static final String SSID = "my_wifi";
		public static final String PASSWORD = "passphrase";
		```

## Launching the demo in simulator mode
- Launch the Run Configuration `AWS IoT PubSub Demo [SIM]` to run it in our simulator
- Take a look at the console to see the traces of the running application

## Launching the demo on a Wi-Fi board
- Launch the Run Configuration `AWS IoT PubSub Demo [SIM]` to generate the binary `microejapp.o`
- Use the generated binary to flash your Wi-Fi board and use a serial console of your choice to see the traces of the running application

The traces should look like this :
```
[INFO] Device connected to the broker.
[INFO] Update listener added, we're now subscribed to the topic awsiot/demo/sample
[INFO] Sample data publishing timer task initialized.
[INFO] Message received on topic awsiot/demo/sample => MicroEJ
[INFO] Message received on topic awsiot/demo/sample => is
[INFO] Message received on topic awsiot/demo/sample => a
[INFO] Message received on topic awsiot/demo/sample => unique
[INFO] Message received on topic awsiot/demo/sample => solution
[INFO] Message received on topic awsiot/demo/sample => for
[INFO] Message received on topic awsiot/demo/sample => building
[INFO] Message received on topic awsiot/demo/sample => Internet
[INFO] Message received on topic awsiot/demo/sample => of
[INFO] Message received on topic awsiot/demo/sample => Things
[INFO] Message received on topic awsiot/demo/sample => and
[INFO] Message received on topic awsiot/demo/sample => embedded
[INFO] Message received on topic awsiot/demo/sample => software
[INFO] Message received on topic awsiot/demo/sample => and
[INFO] Message received on topic awsiot/demo/sample => can
[INFO] Message received on topic awsiot/demo/sample => now
[INFO] Message received on topic awsiot/demo/sample => communicate
[INFO] Message received on topic awsiot/demo/sample => with
[INFO] Message received on topic awsiot/demo/sample => AWS IoT
```

## AWS IoT dashboard
The AWS IoT console provides some tools to monitor the activity on the broker. 
- go in the `Monitor` section of the console to see graphs of successful connections to the broker and statistics on the messaging.
You can also subscribe on a topic through the console in order to see arriving messages from your device: 
- go to `Test`
- in the `Subscription topic` section, indicate the topic to subscribe to, here `awsiot/demo/sample`
- click on `Subscribe to topic`
- when the application is running, you should see messages displayed in the AWS IoT console

# References

- [MicroEJ Developer](https://developer.microej.com)
- [Ivy](https://ant.apache.org/ivy/)
- [AWS console](https://aws.amazon.com/console/)
- [AWS IoT documentation](https://docs.aws.amazon.com/iot/latest/developerguide/iot-console-signin.html) 
- [OpenSSL](https://www.openssl.org/source/)

<!--
	Markdown
	Copyright 2018 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

Hoka Example

An example of use of the Hoka HTTP Server.
EXAMPLE for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: SDK
Last updated:
23 October 2018
+
# Overview
This example of use of the Hoka HTTP Server sets up a simple HTTP server to display pages or serve resources.

**Basic**

Each time a URL if asked by a client (for example an Internet browser) a match is done between this URL and resource in the src/resources source folder.

For example:

http://localhost/html/index.html serves the Java ressource "/html/index.html"

Moreover a custom behaviour is added when asking for the root of the server. The root URL is mapped to a default resource configured in SimpleHTTPSession.DEFAULT\_ROOT\_RESOURCE.

# Requirements
  - EDC 1.2 or later
  - NET 1.2 or later

# Dependencies
  - HOKA 3.0.0 or later
  
# Source
N.A.

# Restrictions
None.

<!--
	Markdown
	Copyright 2017-2018 IS2T. All rights reserved.
	For demonstration purpose only.
	IS2T PROPRIETARY. Use is subject to license terms.
-->

Hoka

An embedded HTTP server library.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
23 October 2018
+
# Overview

The main Hoka library.

Most of the documentation is available in the Hoka documentation folder.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="hoka" rev="+"/>`
	
# Requirements
  - EDC 1.2 or later
  - NET 1.2 or later

# Dependencies
  - EClasspath Lists 1.0.0 or later.

# Source
N.A.

# Restrictions
None.

<!--
	Markdown
	Copyright 2016-2018 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

REST Server Example

This example shows how to configure a simple REST Server.
EXAMPLE for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: SDK
Last updated:
23 October 2018
+
<!--
	Markdown
	Copyright 2017 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
This example show how to configure a simple REST Server.

**Basic**

Each time a URL if asked by a client (for example an Internet browser) a dump of the request is done on the console.

For example:
http://localhost/hello reply the hello for each type request.

# Requirements
  - EDC-1.2 or higher
  - NET-1.0 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

REST Server

A simple REST server implementation over Hoka library.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
23 October 2018
+
# Overview
A simple REST server implementation over Hoka library.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="restserver" rev="+"/>`

# Requirements
  - EDC-1.2 or higher
  - NET-1.0 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.
  - Hoka 3.0.0 or higher
  - Components 3.1.0 or higher
  - EClasspath Lists 1.0.0 or higher
  - EClasspath Collections Utils 1.0.0 or higher

# Source
N/A

# Restrictions
None.

<!--
	Markdown
	Copyright 2014-2018 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

Using IOT Libraries APIs (Sandboxed)

This project gathers simple Sandboxed application using net libraries.
EXAMPLE for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
23 October 2018
+
# Overview
This project gathers simple sandboxed applications using net libraries.

## Requirements
* MicroEJ Studio or SDK 4.1 or later

# Usage
Each subfolder contains a distinct IOT application.

# Changes
- See the change log file [CHANGELOG.md](CHANGELOG.md) located at the root of this repository.

# License
- See the license file [LICENSE.md](LICENSE.md) located at the root of this repository.

SNTP Client

A simple NTP client.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
21 March 2018
+
<!--
	Markdown
	Copyright 2017 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
A simple sntp client.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="sntpclient" rev="..."/>`

# Requirements
  - EDC-1.2 or higher
  - BON-1.2 or higher
  - NET-1.0 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

Hoka

An embedded HTTP server library.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
21 March 2018
+
<!--
	Markdown
	Copyright 2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview

The main Hoka library.

Most of the documentation is available in the Hoka documentation folder.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="hoka" rev="1.+"/>`
	
# Requirements
  - EDC 1.2 or later
  - NET 1.2 or later

# Dependencies
  - EClasspath Lists 1.0.0 or later.

# Source
N.A.

# Restrictions
None.

REST Server

A simple REST server implementation over Hoka library.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
21 March 2018
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
A simple REST server implementation over Hoka library.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="restserver" rev="1.+"/>`

# Requirements
  - EDC-1.2 or higher
  - NET-1.0 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.
  - Hoka 3.0.0 or higher
  - Components 3.1.0 or higher
  - EClasspath Lists 1.0.0 or higher
  - EClasspath Collections Utils 1.0.0 or higher

# Source
N/A

# Restrictions
None.

Using IOT Libraries APIs (Sandboxed)

This project gathers simple Sandboxed application using net libraries.
EXAMPLE for IOT
Supported MicroEJ Version: 4.0
Supported MicroEJ Edition: Studio & SDK
Last updated:
6 July 2017
+
# Overview
This project gathers simple sandboxed applications using net libraries.

## Requirements
* MicroEJ Studio or SDK 4.0 or later

# Usage
Each subfolder contains a distinct IOT application.

# Changes
- See the change log file [CHANGELOG.md](CHANGELOG.md) located at the root of this repository.

# License
- See the license file [LICENSE.md](LICENSE.md) located at the root of this repository.

MQTT Client

MQTT v3 Client for MicroEJ (Paho based).
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
6 July 2017
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
Paho MicroEJ client for MQTT:
  - This is a fork of Paho: https://eclipse.org/paho/clients/java/ from commit 496f94a58a41557ba2401d4ba94bc099a75ba8ef (just after version 1.0.2).
  - Implements MQTT 3.1.1

# Setup
In addition of adding the library in your buildpath, you have to configure your launch.

## Dependency injection:
The library requires some implementations. It comes with default implementations but you can precise yours. 
To precise your own implementation you have to create a system property with the required interface as the key and the corresponding implementation as the value.
To define a system property see the section 6.1 of the MicroEJ Platform Architecture Reference Manual.
	
The library requires an implementation for the following interfaces:
  - org.eclipse.paho.client.mqttv3.MqttClientPersistence
  - org.eclipse.paho.client.mqttv3.internal.NetworkModuleFactory
  - org.eclipse.paho.client.mqttv3.internal.MessageCatalog
  - org.eclipse.paho.client.mqttv3.logging.InternalLoggerFactory
  - org.eclipse.paho.client.mqttv3.util.SystemProperties

For information about this interfaces see the corresponding javadoc.

example: org.eclipse.paho.client.mqttv3.MqttClientPersistence=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence

The default implementations are defined in the `dependencyinjection.properties` file in the package `org.eclipse.paho.client.mqttv3.internal.dependencyinjection` of `mqttv3-microej-version.jar`.
	
In your launch, in the `Main` tab:
- add the chosen implementations in the `Required types` part.
- add the file containing the default implementations in the `Resources` part.

## Threads
Paho requires 4 threads to run. You have to adapt the value `Number of threads` of your launch to take this in account. You can modify this value by going in the `Configuration` tab in the `Target > Memory` section.

## UTF-8
Paho requires UTF-8 encoding to run. In the `Configuration` tab in the `EDC` section check `Embed UTF-8 encoding`.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="org.eclipse.paho" name="mqttv3-microej" rev="1.+"/>`

# Requirements
  - EDC-1.2 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

MQTT SSL Client

SSL Add-on for Paho Client for MQTT v3.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
6 July 2017
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
Paho MicroEJ client for MQTT:
  - This is a fork of Paho: https://eclipse.org/paho/clients/java/ from commit 496f94a58a41557ba2401d4ba94bc099a75ba8ef (just after version 1.0.2).
  - Implements MQTT 3.1.1

# Setup
In addition of adding the library in your buildpath, you have to configure your launch.

## Dependency injection:
The library requires some implementations. It comes with default implementations but you can precise yours. 
To precise your own implementation you have to create a system property with the required interface as the key and the corresponding implementation as the value.
To define a system property see the section 6.1 of the MicroEJ Platform Architecture Reference Manual.
	
The library requires an implementation for the following interfaces:
  - org.eclipse.paho.client.mqttv3.MqttClientPersistence
  - org.eclipse.paho.client.mqttv3.internal.NetworkModuleFactory
  - org.eclipse.paho.client.mqttv3.internal.MessageCatalog
  - org.eclipse.paho.client.mqttv3.logging.InternalLoggerFactory
  - org.eclipse.paho.client.mqttv3.util.SystemProperties

For information about this interfaces see the corresponding javadoc.

example: org.eclipse.paho.client.mqttv3.MqttClientPersistence=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence

The default implementations are defined in the `dependencyinjection.properties` file in the package `org.eclipse.paho.client.mqttv3.internal.dependencyinjection` of `mqttv3-microej-version.jar`.
	
In your launch, in the `Main` tab:
- add the chosen implementations in the `Required types` part.
- add the file containing the default implementations in the `Resources` part.

## Threads
Paho requires 4 threads to run. You have to adapt the value `Number of threads` of your launch to take this in account. You can modify this value by going in the `Configuration` tab in the `Target > Memory` section.

## UTF-8
Paho requires UTF-8 encoding to run. In the `Configuration` tab in the `EDC` section check `Embed UTF-8 encoding`.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="org.eclipse.paho" name="mqttv3-ssl-microej" rev="1.+"/>`

## SSL
The path to the certificate list is defined by the System property `org.eclipse.paho.certificates` by default it is `/certificates/paho.certificates.list`
Your application must embed this file. this file is a list of path to the certificates you want to use (one certificate per line).

# Requirements
  - EDC-1.2 or higher
  - SSL-2.0 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

Z-Wave Base Driver

Library containing ZWave implementation for base driver.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
6 July 2017
+
# Overview
Library containing ZWave implementation for base driver

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot.basedriver" name="zwave" rev="..."/>`

# Requirements
  - EDC-1.2 or higher
  - BON-1.2 or higher
  - ECOM-1.1 or higher
  - KF-1.3 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

REST Client

RESTful services client.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
6 July 2017
+
<!--
	Markdown
	Copyright 2015-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
ej.rest is a tiny RESTful services client. 

## Features
- GET, POST, PUT, DELETE for text, JSON, binary
- Fluent-style API to follow hyperlinks easily
- Complex path queries for JSON (simple tests on fields with operators >,=,< and full boolean expressions (&&,||,!))
- Full support for multipart/form-data

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="restclient" rev="1.+"/>`
	
# Requirements
  - EDC 1.2 or later
  - NET 1.0 or later

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
- Derived from http://beders.github.com/Resty

# Restrictions
None.

# Embedded constraints
Embedded execution environment has a limited amount of memory (RAM, Flash, etc.). Using Resty library in a such environment encourages the developer to precisely manage resources like sockets, files, etc.

Since HTTP 2.0, server defines keep-alive connections for every HTTP connection. When using Resty, developer has to take care of the number of opened sockets. In fact, many sockets can be opened at the same time and stay alive for a long time (keep-alive). To prevent having too much sockets opened, developers have to close the underlying HTTP connection of each REST call. The following code snippet shows how to correctly close such connection:

Resty allows to create access paths into a JSON object with a JSON query path. The parser of these expressions needs RAM buffers. Two different sizes can be configured:
	- The size of the buffers, through the property `ej.rest.jsonquerypath.buffersize`.
	- The expand size of the buffers, through the property `ej.rest.jsonquerypath.expandbuffersize`.

```java
Resty rest = new Resty();
try {
    // Do a REST call
    RawResource raw = this.rest.raw("http://my.url/data");
    // Close the underlying http connection
    raw.http().disconnect();
} catch (IOException e) {
    // something went horribly wrong
    e.printStackTrace();
}
```

Protocol Buffers (protobuf)

This library contains the lite part of Google Protocol Buffer library for java.
LIBRARY for IOT
Supported MicroEJ Version: 4.1
Supported MicroEJ Edition: Studio & SDK
Last updated:
5 July 2017
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
# Overview
This library contains the lite part of Google Protocol Buffer library for java.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="com.google" name="protobuf" rev="2.5.0"/>`

And add the following option into your *.proto files :
> option optimize_for = LITE_RUNTIME;

# Requirements
  - EDC-1.2 or higher

# Dependencies
  - collections-1.0.0 or higher
  - collectionsutil-1.0.0 or higher
  - maps-1.0.0 or higher

# Source

This project was created with all the sources from protobuf-2.5.0.
We removed classes so as to only have the classes necessary for the lite version.
A few minors changes were made in the remaining classes to make it compile.
src contains these classes and the missing classes in EDC / Eclasspath

Differences between original sources and theses source of Protocol Buffer:
- ByteString.toString() has been modified to avoid String.format() (twice)
- GeneratedMessageLite.readResolve() has been commented out to avoid reflection on methods

# Restrictions

Protocol Buffers (protobuf)

Protocol buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data.
LIBRARY for IOT
Supported MicroEJ Version: 4.0
Supported MicroEJ Edition: Studio & SDK
Last updated:
14 September 2016
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
# Overview
This library contains the lite part of Google Protocol Buffer library for java.

## Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="com.google" name="protobuf" rev="2.5.0"/>`

And add the following option into your *.proto files :
> option optimize_for = LITE_RUNTIME;

# Requirements
  - EDC-1.2 or higher

## Dependencies
  - collections-1.0.0 or higher
  - collectionsutil-1.0.0 or higher
  - maps-1.0.0 or higher

# Source

This project was created with all the sources from protobuf-2.5.0.
We removed classes so as to only have the classes necessary for the lite version.
A few minors changes were made in the remaining classes to make it compile.
src contains these classes and the missing classes in EDC / Eclasspath

Differences between original sources and theses source of Protocol Buffer:
- ByteString.toString() has been modified to avoid String.format() (twice)
- GeneratedMessageLite.readResolve() has been commented out to avoid reflection on methods

## Restrictions

REST Client

RESTful services client.
LIBRARY for IOT
Supported MicroEJ Version: 4.0
Supported MicroEJ Edition: Studio & SDK
Last updated:
14 September 2016
+
<!--
	Markdown
	Copyright 2015-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
ej.rest is a tiny RESTful services client. 

## Features
- GET, POST, PUT, DELETE for text, JSON, binary
- Fluent-style API to follow hyperlinks easily
- Complex path queries for JSON (simple tests on fields with operators >,=,< and full boolean expressions (&&,||,!))
- Full support for multipart/form-data

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="ej.library.iot" name="restclient" rev="1.+"/>`
	
# Requirements
  - EDC 1.2 or later
  - NET 1.0 or later

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
- Derived from http://beders.github.com/Resty

# Restrictions
None.

# Embedded constraints
Embedded execution environment has a limited amount of memory (RAM, Flash, etc.). Using Resty library in a such environment encourages the developer to precisely manage resources like sockets, files, etc.

Since HTTP 2.0, server defines keep-alive connections for every HTTP connection. When using Resty, developer has to take care of the number of opened sockets. In fact, many sockets can be opened at the same time and stay alive for a long time (keep-alive). To prevent having too much sockets opened, developers have to close the underlying HTTP connection of each REST call. The following code snippet shows how to correctly close such connection:

Resty allows to create access paths into a JSON object with a JSON query path. The parser of these expressions needs RAM buffers. Two different sizes can be configured:
	- The size of the buffers, through the property `ej.rest.jsonquerypath.buffersize`.
	- The expand size of the buffers, through the property `ej.rest.jsonquerypath.expandbuffersize`.

```java
Resty rest = new Resty();
try {
    // Do a REST call
    RawResource raw = this.rest.raw("http://my.url/data");
    // Close the underlying http connection
    raw.http().disconnect();
} catch (IOException e) {
    // something went horribly wrong
    e.printStackTrace();
}
```

MQTT Client

MQTT v3 Client for MicroEJ (Paho based).
LIBRARY for IOT
Supported MicroEJ Version: 4.0
Supported MicroEJ Edition: Studio & SDK
Last updated:
14 September 2016
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
Paho MicroEJ client for MQTT:
  - This is a fork of Paho: https://eclipse.org/paho/clients/java/ from commit 496f94a58a41557ba2401d4ba94bc099a75ba8ef (just after version 1.0.2).
  - Implements MQTT 3.1.1

# Setup
In addition of adding the library in your buildpath, you have to configure your launch.

## Dependency injection:
The library requires some implementations. It comes with default implementations but you can precise yours. 
To precise your own implementation you have to create a system property with the required interface as the key and the corresponding implementation as the value.
To define a system property see the section 6.1 of the MicroEJ Platform Architecture Reference Manual.
	
The library requires an implementation for the following interfaces:
  - org.eclipse.paho.client.mqttv3.MqttClientPersistence
  - org.eclipse.paho.client.mqttv3.internal.NetworkModuleFactory
  - org.eclipse.paho.client.mqttv3.internal.MessageCatalog
  - org.eclipse.paho.client.mqttv3.logging.InternalLoggerFactory
  - org.eclipse.paho.client.mqttv3.util.SystemProperties

For information about this interfaces see the corresponding javadoc.

example: org.eclipse.paho.client.mqttv3.MqttClientPersistence=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence

The default implementations are defined in the `dependencyinjection.properties` file in the package `org.eclipse.paho.client.mqttv3.internal.dependencyinjection` of `mqttv3-microej-version.jar`.
	
In your launch, in the `Main` tab:
- add the chosen implementations in the `Required types` part.
- add the file containing the default implementations in the `Resources` part.

## Threads
Paho requires 4 threads to run. You have to adapt the value `Number of threads` of your launch to take this in account. You can modify this value by going in the `Configuration` tab in the `Target > Memory` section.

## UTF-8
Paho requires UTF-8 encoding to run. In the `Configuration` tab in the `EDC` section check `Embed UTF-8 encoding`.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="org.eclipse.paho" name="mqttv3-microej" rev="1.+"/>`

# Requirements
  - EDC-1.2 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

MQTT SSL Client

SSL Add-on for Paho MicroEJ Client for MQTT v3.
LIBRARY for IOT
Supported MicroEJ Version: 4.0
Supported MicroEJ Edition: Studio & SDK
Last updated:
14 September 2016
+
<!--
	Markdown
	Copyright 2014-2016 IS2T. All rights reserved.
	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->

# Overview
Paho MicroEJ client for MQTT:
  - This is a fork of Paho: https://eclipse.org/paho/clients/java/ from commit 496f94a58a41557ba2401d4ba94bc099a75ba8ef (just after version 1.0.2).
  - Implements MQTT 3.1.1

# Setup
In addition of adding the library in your buildpath, you have to configure your launch.

## Dependency injection:
The library requires some implementations. It comes with default implementations but you can precise yours. 
To precise your own implementation you have to create a system property with the required interface as the key and the corresponding implementation as the value.
To define a system property see the section 6.1 of the MicroEJ Platform Architecture Reference Manual.
	
The library requires an implementation for the following interfaces:
  - org.eclipse.paho.client.mqttv3.MqttClientPersistence
  - org.eclipse.paho.client.mqttv3.internal.NetworkModuleFactory
  - org.eclipse.paho.client.mqttv3.internal.MessageCatalog
  - org.eclipse.paho.client.mqttv3.logging.InternalLoggerFactory
  - org.eclipse.paho.client.mqttv3.util.SystemProperties

For information about this interfaces see the corresponding javadoc.

example: org.eclipse.paho.client.mqttv3.MqttClientPersistence=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence

The default implementations are defined in the `dependencyinjection.properties` file in the package `org.eclipse.paho.client.mqttv3.internal.dependencyinjection` of `mqttv3-microej-version.jar`.
	
In your launch, in the `Main` tab:
- add the chosen implementations in the `Required types` part.
- add the file containing the default implementations in the `Resources` part.

## Threads
Paho requires 4 threads to run. You have to adapt the value `Number of threads` of your launch to take this in account. You can modify this value by going in the `Configuration` tab in the `Target > Memory` section.

## UTF-8
Paho requires UTF-8 encoding to run. In the `Configuration` tab in the `EDC` section check `Embed UTF-8 encoding`.

# Usage
Add the following line to your `module.ivy` or your `ivy.xml`:
> `<dependency org="org.eclipse.paho" name="mqttv3-ssl-microej" rev="1.+"/>`

## SSL
The path to the certificate list is defined by the System property `org.eclipse.paho.certificates` by default it is `/certificates/paho.certificates.list`
Your application must embed this file. this file is a list of path to the certificates you want to use (one certificate per line).

# Requirements
  - EDC-1.2 or higher
  - SSL-2.0 or higher

# Dependencies
_All dependencies are retrieved transitively by Ivy resolver_.

# Source
N/A

# Restrictions
None.

MQTT Paho

Paho MQTT Client for MicroEJ.
LIBRARY for IOT
Supported MicroEJ Version: 4.0
Supported MicroEJ Edition: SDK
Last updated:
30 June 2016
+
# Overview
Paho MicroEJ client for MQTT:
- This is a fork of Paho: https://eclipse.org/paho/clients/java/ from commit 496f94a58a41557ba2401d4ba94bc099a75ba8ef (just after version 1.0.2).
- Implements MQTT 3.1.1


Some useful tutorials:
- http://www.infoq.com/articles/practical-mqtt-with-paho
- https://developer.motorolasolutions.com/docs/DOC-2315 android oriented

	
## Setup
In addition of adding the library in your buildpath, you have to configure your launch.

### Dependency injection:
The library requires some implementations. It comes with default implementations but you can precise yours. 
To precise your own implementation you have to create a system property with the required interface as the key and the corresponding implementation as the value.
To define a system property see the section 6.1 of the MicroEJ Platform Architecture Reference Manual.
	
The library requires an implementation for the following interfaces:
- org.eclipse.paho.client.mqttv3.MqttClientPersistence
- org.eclipse.paho.client.mqttv3.internal.NetworkModuleFactory
- org.eclipse.paho.client.mqttv3.internal.MessageCatalog
- org.eclipse.paho.client.mqttv3.logging.InternalLoggerFactory
- org.eclipse.paho.client.mqttv3.util.SystemProperties

For information about this interfaces see the corresponding javadoc.

example: org.eclipse.paho.client.mqttv3.MqttClientPersistence=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence

The default implementations are defined in the `dependencyinjection.properties` file in the package `org.eclipse.paho.client.mqttv3.internal.dependencyinjection` of `mqttv3-microej-version.jar`.
	
In your launch, in the `Main` tab:
- add the chosen implementations in the `Required types` part.
- add the file containing the default implementations in the `Resources` part.

### Threads
Paho requires 4 threads to run. You have to adapt the value `Number of threads` of your launch to take this in account. You can modify this value by going in the `Configuration` tab in the `Target > Memory` section.

### UTF-8
Paho requires UTF-8 encoding to run. In the `Configuration` tab in the `EDC` section check `Embed UTF-8 encoding`.

MQTT Paho

MQTT v3 Client for MicroEJ (Paho based).
LIBRARY for IOT
Supported MicroEJ Version: 3.1
Supported MicroEJ Edition: SDK
Last updated:
23 July 2015
+
# Overview
Paho MicroEJ client for MQTT:
- This is a fork of Paho: https://eclipse.org/paho/clients/java/ from commit 496f94a58a41557ba2401d4ba94bc099a75ba8ef (just after version 1.0.2).
- Implements MQTT 3.1.1


Some useful tutorials:
- http://www.infoq.com/articles/practical-mqtt-with-paho
- https://developer.motorolasolutions.com/docs/DOC-2315 android oriented

	
## Setup
In addition of adding the library in your buildpath, you have to configure your launch.

### Dependency injection:
The library requires some implementations. It comes with default implementations but you can precise yours. 
To precise your own implementation you have to create a system property with the required interface as the key and the corresponding implementation as the value.
To define a system property see the section 6.1 of the MicroEJ Platform Architecture Reference Manual.
	
The library requires an implementation for the following interfaces:
- org.eclipse.paho.client.mqttv3.MqttClientPersistence
- org.eclipse.paho.client.mqttv3.internal.NetworkModuleFactory
- org.eclipse.paho.client.mqttv3.internal.MessageCatalog
- org.eclipse.paho.client.mqttv3.logging.InternalLoggerFactory
- org.eclipse.paho.client.mqttv3.util.SystemProperties

For information about this interfaces see the corresponding javadoc.

example: org.eclipse.paho.client.mqttv3.MqttClientPersistence=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence

The default implementations are defined in the `dependencyinjection.properties` file in the package `org.eclipse.paho.client.mqttv3.internal.dependencyinjection` of `mqttv3-microej-version.jar`.
	
In your launch, in the `Main` tab:
- add the chosen implementations in the `Required types` part.
- add the file containing the default implementations in the `Resources` part.

### Threads
Paho requires 4 threads to run. You have to adapt the value `Number of threads` of your launch to take this in account. You can modify this value by going in the `Configuration` tab in the `Target > Memory` section.

### UTF-8
Paho requires UTF-8 encoding to run. In the `Configuration` tab in the `EDC` section check `Embed UTF-8 encoding`.

MQTT Example

MQTT example for MicroEJ.
EXAMPLE for IOT
Supported MicroEJ Version: 3.1
Supported MicroEJ Edition: SDK
Last updated:
23 July 2015
+
# Overview
The following projects illustrate the Paho library.

## MQTTHelloWorld
The project `HelloWorld` shows the 2 main features of Paho:
- the publication of messages in a topic with the `HelloWorldPublisher` entry point.
- the subscription to a topic with the `HelloWorldSubscriber` entry point.

### Requirements
- JRE 7 (or later) x86.
- MicroEJ 3.1 or later.
- Java platform with (at least) EDC-1.2, NET-EMBEDDED-1.0, the MicroEJ fork of org.eclipse.paho.client (the Paho library is set as an ivy dependancy in module.ivy and will be resolved by ivy).

### Project structure
- `src/main/java`
  - Java sources
- `launches/`: MicroEJ launches

### Configuration
- Set your MQTT broker url by changing the value of `com.is2t.example.mqtt.HelloWorldConstants.BROKER`.
- Set your network configuration by going in your launch in the `Configuration` tab in the `Net Embedded > Network Settings` section.

### Launches
A Simulation and an Embedded launches are available for each entry point.

## Changes
- MQTTHelloWorld example.

## License
See the license file `LICENSE.md` located at the root of this repository.

Hoka

An embedded HTTP server library.
LIBRARY for IOT
Supported MicroEJ Version: 3.1
Supported MicroEJ Edition: SDK
Last updated:
16 April 2015
+
# Overview
This repository contains the Hoka HTTP server and dependencies as well as an example of use to set up a HTTP server.

### Structure
Structure of the repository :

- LibraryJava-hoka
   - hoka
   - hoka-example
   - socket-connector-core
   - socket-connector-netembedded

Each folder is an Eclipse/MicroEJ project. Each project has its own README and LICENSE requirements.

## Setup
Import the projects in MicroEJ.

### Requirements
- JRE 7 x86
- a Java platform with NET EMBEDDED 1.0. There is currently no platform with NET EMBEDDED 1.0 delivered in MicroEJ 3.1
- MicroEJ 3.1 or later

## Usage
Import the projects. The example project should be run with a MicroEJ launch by:

- Right-clicking the SimpleServer main class
- Selecting Run As > Run Configurations...
- Double-clicking on MicroEJ Application
- Adding the resources (/html/index.html and /png/microej.png) on the Main tab
- Selecting a platform with net embedded in the Execution tab
- Running!

## Changes
Feb 2015: initial release
Share Hoka and its simple example.

XML

This MicroEJ project presents how to parse XML in an embedded environment.
EXAMPLE for IOT
Supported MicroEJ Version: 3.1
Supported MicroEJ Edition: SDK
Last updated:
16 April 2015
+
# Overview
This eclipse project presents how to parse XML in MicroEJ environment. It details how to use **XML Pull** parsers such as **KXmlParser** and **MXParser**.

For more information about XML pull parsing, please refer to http://www.xmlpull.org.


### Requirements

- JRE 7 x86
- MicroEJ 3.0 at least

### Project structure

- `src/`
  - Java sources
  - XML resources
- `dist/`: when `build.ant` is called, a zip containing the project is created in this folder
- `launches/`: MicroEJ launches
- `lib/`: XML parsers libraries (available at http://www.xmlpull.org/impls.shtml)
- `build.ant`: ant build file meant to archive this project
- `LICENCE.md`
- `README.md`

### Configuration
Two different parsers are available: **KXmlParser** and **MXParser**. To switch between these parsers, open the build path (Right-click on the project, _Build Path_, _Configure Build Path_, _Libraries_), choose between `kxml2-2.3.0.jar` (KXmlParser) and `xpp3_min-1.1.4c.jar` (MXParser), remove the other one.

## Usage
To launch the application, right-click on the project, select _Run as_, _MicroEJ Application_ and choose _ReadPoem (Simulation)_. Another launcher is available to execute on the target board.

## Changes
- Simple example

## License
See the license file `LICENSE.md` located at the root of this repository.