Mbed Client sample for GR-LYCHEE where ZXing is incorporated.

Dependencies:   DisplayApp AsciiFont

Fork of GR-PEACH_mbed-os-client-ZXingSample by Renesas

Overview

This sample program shows how to use mbed Client together with ZXing which is an open-source, multi-format 1D/2D barcode image processing library. For more info on ZXing, please refer to https://github.com/zxing/zxing.

Required hardware

Application setup

  1. Select the connection type. For details, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Connection-type.
  2. Set the client credentials. For details, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Client-credentials.
  3. Change Wifi settings. For details, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Wifi-settings.

Building the example

To build this example:

  1. Import this example onto mbed Compiler.
  2. Configure the example in accordance with Application setup.
  3. Compile the example on mbed Compiler and download the resultant binary file.
  4. Plug the micro-USB cable into the OpenSDA port which lies on the next to the RESET button.
  5. Copy the binary previously downloaded to your PC to GR-LYCHEE to flash this example. When the copy is successfully completed, the board is ready to work.
  6. Press the RESET button on the board to run the example.
  7. For verification, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Monitoring-the-application.

Application resources

This example exposes four resources listed below:

  1. 3202/0/5700. Decode result of barcode data input from camera (GET).
  2. 3201/0/5850. Blink function, blinks LED when executed (POST).
  3. 3201/0/5853. Blink pattern, used by the blink function to determine how to blink. In the format of 1000:500:1000:500:1000:500 (PUT).
  4. 3201/0/5855. Blink color, used by the blink function. Any of green, yellow, orange and red is acceptable (PUT).

Files at this revision

API Documentation at this revision

Comitter:
dkato
Date:
Tue Mar 28 11:02:34 2017 +0000
Parent:
1:5d3134f9efae
Child:
3:426b9477927d
Commit message:
Memory-saving version

Changed in this revision

AsciiFont.lib Show annotated file Show diff for this revision Revisions of this file
GW_Binary/gateway6LoWPANDynamic.bin Show diff for this revision Revisions of this file
GW_Binary/gateway6LoWPANStatic.bin Show diff for this revision Revisions of this file
GW_Binary/gatewayThreadDynamic.bin Show diff for this revision Revisions of this file
GW_Binary/gatewayThreadStatic.bin Show diff for this revision Revisions of this file
GraphicsFramework.lib Show annotated file Show diff for this revision Revisions of this file
LCD_shield_config.lib Show annotated file Show diff for this revision Revisions of this file
LWIPBP3595Interface_for_mbed-os.lib Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
R_BSP.lib Show annotated file Show diff for this revision Revisions of this file
configs/eth-wifi-mbedignore Show annotated file Show diff for this revision Revisions of this file
configs/eth_v4.json Show annotated file Show diff for this revision Revisions of this file
configs/eth_v6.json Show annotated file Show diff for this revision Revisions of this file
configs/mesh-mbedignore Show annotated file Show diff for this revision Revisions of this file
configs/mesh_6lowpan.json Show annotated file Show diff for this revision Revisions of this file
configs/mesh_6lowpan_subg.json Show annotated file Show diff for this revision Revisions of this file
configs/mesh_thread.json Show annotated file Show diff for this revision Revisions of this file
configs/wifi_esp8266_v4.json Show annotated file Show diff for this revision Revisions of this file
configs/wifi_odin_v4.json Show annotated file Show diff for this revision Revisions of this file
configs/wifi_v4.json Show annotated file Show diff for this revision Revisions of this file
docs/img/Radio_Identifications.png Show diff for this revision Revisions of this file
docs/img/Radio_Identifications_GW.png Show diff for this revision Revisions of this file
docs/img/ep_lookup.PNG Show annotated file Show diff for this revision Revisions of this file
docs/radio_module_identify.md Show diff for this revision Revisions of this file
easy-connect-gr-peach.lib Show annotated file Show diff for this revision Revisions of this file
esp8266-driver.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-client.lib Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
mbedtls_mbed_client_config.h Show annotated file Show diff for this revision Revisions of this file
pal.lib Show annotated file Show diff for this revision Revisions of this file
simpleclient.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/ImageReaderSource.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing_config.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing_lib.ar Show annotated file Show diff for this revision Revisions of this file
zxing_main.cpp Show annotated file Show diff for this revision Revisions of this file
zxing_main.h Show annotated file Show diff for this revision Revisions of this file
--- a/AsciiFont.lib	Wed Oct 19 15:58:43 2016 +0900
+++ b/AsciiFont.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Renesas/code/AsciiFont/#0d8bc371d109
+http://developer.mbed.org/teams/Renesas/code/AsciiFont/#1eaa4942db53
Binary file GW_Binary/gateway6LoWPANDynamic.bin has changed
Binary file GW_Binary/gateway6LoWPANStatic.bin has changed
Binary file GW_Binary/gatewayThreadDynamic.bin has changed
Binary file GW_Binary/gatewayThreadStatic.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GraphicsFramework.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Renesas/code/GraphicsFramework/#80f4beab1243
--- a/LCD_shield_config.lib	Wed Oct 19 15:58:43 2016 +0900
+++ b/LCD_shield_config.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/dkato/code/LCD_shield_config/#5bc6a60b8ff5
+https://developer.mbed.org/users/dkato/code/LCD_shield_config/#720a62b44d67
--- a/LWIPBP3595Interface_for_mbed-os.lib	Wed Oct 19 15:58:43 2016 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/dkato/code/LWIPBP3595Interface_STA_for_mbed-os/#590c87b7dcc2
--- a/README.md	Wed Oct 19 15:58:43 2016 +0900
+++ b/README.md	Tue Mar 28 11:02:34 2017 +0000
@@ -20,9 +20,9 @@
 * To get the application registering successfully on non K64F boards , you need Edit the `mbed_app.json` file to add `NULL_ENTROPY`  feature for mbedTLS:
 
 ```
-""macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"",
-            "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES",
-            "MBEDTLS_TEST_NULL_ENTROPY"],
+"RZ_A1H": {
+    "target.macros_add": ["MBEDTLS_TEST_NULL_ENTROPY", "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES"]
+},
 ```
 
 ## Required software
@@ -44,13 +44,13 @@
 
 ### Connection type
 
-The application uses Ethernet as the default connection type. To change the connection type, set one of them in `mbed_app.json`. For example, to enable 6LoWPAN ND mode:
+The application uses "NO_CONNECT" as the default connection type. To change the connection type, set one of them in `mbed_app.json`. For example, to enable Ethernet mode:
 
 ```json
-    "network-interface": {
-        "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD.",
-        "value": "MESH_LOWPAN_ND"
-    }
+    "network-interface":{
+        "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595, NO_CONNECT",
+        "value": "ETHERNET"
+    },
 ```
 
 ### Client credentials
@@ -67,6 +67,18 @@
 
 - An Ethernet cable.
 - An Ethernet connection to the internet.
+- MAC address setting. To set MAC address, add fllowing function to main.cpp. (When using Wifi, setting of MAC address is not necessary.) 
+```
+// set mac address
+void mbed_mac_address(char *mac) {
+    mac[0] = 0x00;
+    mac[1] = 0x02;
+    mac[2] = 0xF7;
+    mac[3] = 0xF0;
+    mac[4] = 0x00;
+    mac[5] = 0x00;
+}
+```
 
 ### Wi-Fi settings (BP3595)
 
@@ -76,10 +88,10 @@
 1. Mount the WiFi module onto [Renesas GR-PEACH](https://developer.mbed.org/platforms/Renesas-GR-PEACH/)
 1. In the `mbed_app.json` file, change
 ```json
-    "network-interface": {
-        "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD.",
-        "value": "WIFI"
-    }
+    "network-interface":{
+        "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595, NO_CONNECT",
+        "value": "WIFI_BP3595"
+    },
 ```
 
 Provide your WiFi SSID and password here and leave `\"` in the beginning and end of your SSID and password (as shown in the example below). Otherwise, the example cannot pick up the SSID and password in correct format.
@@ -94,11 +106,11 @@
     }
 ```
 
-Specify the security protocol in accordance with your wireless network. By default, NSAPI_SECURITY_WPA2 is specified. That means WPA2 is available. If you would like to use WEP instead of WPA2, please specify NSAPI_SECURITY_WEP here.
+Specify the security protocol in accordance with your wireless network. By default, NSAPI_SECURITY_WPA_WPA2 is specified. That means WPA and WPA2 are available. If you would like to use WEP instead of WPA2, please specify NSAPI_SECURITY_WEP here.
 ```json
     "wifi-security": {
-        "help": "Type of encryption for connection",
-        "value": "NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WEP"
+        "help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
+        "value": "NSAPI_SECURITY_WPA_WPA2"
     }
 ```
 
@@ -108,38 +120,63 @@
 
 ### IP address setup
 
-This example uses IPv4 to communicate with the [mbed Device Connector Server](https://api.connector.mbed.com) except for 6LoWPAN ND and Thread. The example program should automatically get an IPv4 address from the router when connected over Ethernet.
-
+This example uses IPv4 to communicate with the [mbed Device Connector Server](https://api.connector.mbed.com) except for 6LoWPAN ND and Thread. 
+The example program should automatically get an IP address from the router when connected over Ethernet or WiFi.
 If your network does not have DHCP enabled, you have to manually assign a static IP address to the board. We recommend having DHCP enabled to make everything run smoothly.
 
 ### Changing socket type
 
-Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default is UDP. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.
+Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default and only allowed value is UDP for Thread and 6LoWPAN. TCP is the default for other connections. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.
 
 To change the binding mode:
 
-1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP`.
-1. To switch to TCP, change it to `M2MInterface::TCP`.
+1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP` for mesh and `M2MInterface::TCP` for others.
+1. To switch to UDP, change it to `M2MInterface::UDP`.
 1. Rebuild and flash the application.
 
 <span class="tips">**Tip:** The instructions in this document remain the same, irrespective of the socket mode you select.</span>
 
+Possible socket types per connection:
+
+| Network  interface                    | UDP   | TCP | 
+| ------------------------------|:-----:|:-----:|
+| Ethernet (IPv4)               |   X   |   X   | 
+| Ethernet (IPv6)               |   X   |       | 
+| Wifi (IPv4)                   |   X   |   X   |
+| Wifi (IPv6) - Not supported   |       |       |
+| 6LoWPAN/Thread (IPv6)         |   X   |       |
+
 ## Building the example
 
-To build the example application:
+To build the example using mbed CLI:
 
-1. Clone [this](https://github.com/ARMmbed/mbed-os-example-client) repository.
 1. Open a command line tool and navigate to the project’s directory.
-1. Update mbed-os sources using the `mbed update` command.
-1. [Configure](#application-setup) the client application.
-1. Build the application by selecting the hardware board and build the toolchain using the command `mbed compile -m RZ_A1H -t GCC_ARM -c -j0`. mbed-cli builds a binary file under the project’s `.build` directory.
-1. Plug the Ethernet cable into the board if you are using Ethernet mode.
-1. If you are using 6LoWPAN ND or Thread mode, connect and power on the gateway first.
-1. Plug the micro-USB cable into the **OpenSDA** port. The board is listed as a mass-storage device.
-1. Drag the binary `.build/RZ_A1H/GCC_ARM/mbed-os-example-client.bin` to the board to flash the application.
-1. The board is automatically programmed with the new binary. A flashing LED on it indicates that it is still working. When the LED stops blinking, the board is ready to work.
-1. Press the **RESET** button on the board to run the program.
-1. For verification, continue to the [Monitoring the application](#monitoring-the-application) chapter.
+
+2. Import this example:
+
+    ```
+    mbed import http://mbed.org/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/
+    ```
+
+3. To build the application, select the hardware board and build the toolchain using the command:
+
+    ```
+    mbed compile -m RZ_A1H -t GCC_ARM -c
+    ```
+
+    mbed CLI builds a binary file under the project’s `BUILD/` directory.
+
+4. Plug the Ethernet cable into the board if you are using Ethernet mode.
+
+5. Plug the micro-USB cable into the **OpenSDA** port. The board is listed as a mass-storage device.
+
+6. Drag the binary `BUILD/RZ_A1H/GCC_ARM/GR-PEACH_mbed-os-client-ZXingSample.bin` to the board to flash the application.
+
+7. The board is automatically programmed with the new binary. A flashing LED on it indicates that it is still working. When the LED stops blinking, the board is ready to work.
+
+8. Press the **Reset** button on the board to run the program.
+
+9. For verification, continue to the [Monitoring the application](#monitoring-the-application) chapter.
 
 ## Monitoring the application
 
@@ -149,15 +186,17 @@
 
 
 ```
-Starting mbed Client example...
-Using <Network Interface>
+Starting mbed Client example in IPv4 mode
+[EasyConnect] Using Ethernet
+[EasyConnect] Connected to Network successfully
+[EasyConnect] IP address  192.168.8.110
+[EasyConnect] MAC address 5c:cf:7f:86:de:bf
 
-Connected to Network successfully
-IP address xxx.xxx.xxx.xxx
+SOCKET_MODE : TCP
 
-SOCKET_MODE : UDP
 Connecting to coap://api.connector.mbed.com:5684
 
+Registered object succesfully!
 ```
 
 <span class="notes">**Note:** Device name is the endpoint name you will need later on when [testing the application](https://github.com/ARMmbed/mbed-os-example-client#testing-the-application) chapter.</span>
@@ -183,10 +222,11 @@
 
 ### Application resources
 
-The application exposes three [resources](https://docs.mbed.com/docs/mbed-device-connector-web-interfaces/en/latest/#the-mbed-device-connector-data-model):
+The application exposes four [resources](https://docs.mbed.com/docs/mbed-device-connector-web-interfaces/en/latest/#the-mbed-device-connector-data-model):
 
 1. `3202/0/5700`. Decoded String of Barcode Data (GET).
 2. `3201/0/5850`. Blink function, blinks `LED1` when executed (POST).
 3. `3201/0/5853`. Blink pattern, used by the blink function to determine how to blink. In the format of `1000:500:1000:500:1000:500` (PUT).
+4. `3201/0/5855`. Blink color, used by the blink function. Any of `red`, `green`, `blue`, `cyan`, `yellow` and `magenta` is acceptable (PUT). 
 
 For information on how to get notifications when resource 1 changes, or how to use resources 2 and 3, take a look at the [mbed Device Connector Quick Start](https://github.com/Osamu-Nakamura/mbed-connector-api-node-quickstart).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/R_BSP.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Renesas/code/R_BSP/#fb9eda52224e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth-wifi-mbedignore	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,3 @@
+easy-connect/atmel-rf-driver/*
+easy-connect/mcr20a-rf-driver/*
+easy-connect/stm-spirit1-rf-driver/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth_v4.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,22 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "ETHERNET"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["LWIP", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "lwip.ipv4-enabled": true,
+            "lwip.ipv6-enabled": false,
+            "mbed-trace.enable": 0
+        },
+            "UBLOX_EVK_ODIN_W2": {
+            "target.device_has_remove": ["EMAC"]
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth_v6.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,22 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "ETHERNET"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["LWIP", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "lwip.ipv4-enabled": false,
+            "lwip.ipv6-enabled": true,
+            "mbed-trace.enable": 0
+        },
+            "UBLOX_EVK_ODIN_W2": {
+            "target.device_has_remove": ["EMAC"]
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh-mbedignore	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,1 @@
+easy-connect/esp8266-driver/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh_6lowpan.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,23 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "MESH_LOWPAN_ND"
+        },
+        "mesh_radio_type": {
+        	"help": "options are ATMEL, MCR20",
+        	"value": "ATMEL"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
+            "mbed-mesh-api.6lowpan-nd-channel": 12,
+            "mbed-trace.enable": 0
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh_6lowpan_subg.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,26 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "MESH_LOWPAN_ND"
+        },
+        "mesh_radio_type": {
+        	"help": "options are ATMEL, MCR20, SPIRIT1",
+        	"value": "SPIRIT1"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "spirit1.mac-address": "{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7}",
+            "target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "mbed-mesh-api.6lowpan-nd-security-mode": "PSK",
+            "mbed-mesh-api.6lowpan-nd-channel-page": 2,
+            "mbed-mesh-api.6lowpan-nd-channel": 1,
+            "mbed-mesh-api.6lowpan-nd-channel-mask": "(1<<1)",
+            "mbed-trace.enable": 0
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh_thread.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,23 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "MESH_THREAD"
+        },
+        "mesh_radio_type": {
+        	"help": "options are ATMEL, MCR20",
+        	"value": "ATMEL"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["NANOSTACK", "THREAD_ROUTER", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "mbed-mesh-api.thread-config-channel": 22,
+            "mbed-mesh-api.thread-config-panid": "0x0700",
+            "mbed-trace.enable": 0
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_esp8266_v4.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,43 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "WIFI_ESP8266"
+        },
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"Password\""
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "D1"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "D0"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["LWIP", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "lwip.ipv4-enabled": true,
+            "lwip.ipv6-enabled": false,
+            "mbed-trace.enable": 0
+        },
+        "NUCLEO_F401RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        },
+        "NUCLEO_F411RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_odin_v4.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,43 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "WIFI_ODIN"
+        },
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"Password\""
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "D1"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "D0"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["LWIP", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines":true,
+            "lwip.ipv4-enabled": true,
+            "lwip.ipv6-enabled": false,
+            "mbed-trace.enable": 0
+        },
+        "NUCLEO_F401RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        },
+        "NUCLEO_F411RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_v4.json	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,43 @@
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+            "value": "WIFI_ESP8266"
+        },
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"Password\""
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "D1"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "D0"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["LWIP", "COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "lwip.ipv4-enabled": true,
+            "lwip.ipv6-enabled": false,
+            "mbed-trace.enable": 0
+        },
+        "NUCLEO_F401RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        },
+        "NUCLEO_F411RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        }
+    }
+}
Binary file docs/img/Radio_Identifications.png has changed
Binary file docs/img/Radio_Identifications_GW.png has changed
Binary file docs/img/ep_lookup.PNG has changed
--- a/docs/radio_module_identify.md	Wed Oct 19 15:58:43 2016 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-## Radio module identification
-
-* Make sure that you are using the same radio modules on both server and client sides:
-
-	* If the radio module on the gateway router supports the 2.4 GHz frequency band, the client side must have an mbed 6LoWPAN shield that uses a 2.4 GHz radio module (such as Atmel AT86RF233).
-
-	* If the radio module on the gateway router supports the sub-GHz frequency band, the client side must have an mbed 6LoWPAN shield that uses a sub-GHz radio module (such as Atmel AT86RF212B).
-
-* An easy way to identify which frequency band your setup uses is to check the **Antenna size** on the radio module:
-
-	* The sub-GHz band antenna is larger than the 2.4 GHz antenna.
-
-	* For the client side (mbed 6LoWPAN shield connected to an FRDM-K64F board), see the image below:
-  ![](img/Radio_Identifications.png) 
-
-	* For the gateway router, see the image below:
-  ![](img/Radio_Identifications_GW.png) 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/easy-connect-gr-peach.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/dkato/code/easy-connect-gr-peach/#34fe4f11941d
--- a/esp8266-driver.lib	Wed Oct 19 15:58:43 2016 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://github.com/ARMmbed/esp8266-driver/#450cc128865ffb90b5cbfe5af193621644024fa7
--- a/main.cpp	Wed Oct 19 15:58:43 2016 +0900
+++ b/main.cpp	Tue Mar 28 11:02:34 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 ARM Limited. All rights reserved.
+ * Copyright (c) 2015, 2016 ARM Limited. All rights reserved.
  * SPDX-License-Identifier: Apache-2.0
  * Licensed under the Apache License, Version 2.0 (the License); you may
  * not use this file except in compliance with the License.
@@ -13,55 +13,49 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "simpleclient.h"
+#include "mbed-trace/mbed_trace.h"
+#include "mbed.h"
+#include "zxing_main.h"
+
+// Network interaction must be performed outside of interrupt context
+osThreadId mainThread;
+
+#define NO_CONNECT         (-1)
+
+#if MBED_CONF_APP_NETWORK_INTERFACE == NO_CONNECT
+
+static void callback_zxing(char * addr, int size) {
+    printf("%s\r\n", addr);
+}
+
+// Entry point to the program
+int main() {
+    // Keep track of the main thread
+    mainThread = osThreadGetId();
+    printf("no connect\n");
+    mbed_trace_init();
+    zxing_init(&callback_zxing);
+
+    while (1) {
+        zxing_loop();
+        Thread::wait(5);
+    }
+}
+
+#else // MBED_CONF_APP_NETWORK_INTERFACE != NO_CONNECT
+
+#define __STDC_FORMAT_MACROS
 #include <string>
 #include <sstream>
 #include <vector>
-#include "mbed-trace/mbed_trace.h"
-
 #include "security.h"
-
-#include "mbed.h"
-#include "rtos.h"
-
-#define ETHERNET        1
-#define WIFI            2
-#define MESH_LOWPAN_ND  3
-#define MESH_THREAD     4
-
-#define STRINGIFY(s) #s
+#include "simpleclient.h"
+#include "mbedtls/entropy_poll.h"
 
-#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI
-#if(1) //bp3595
-#include "LWIPBP3595Interface.h"
-LWIPBP3595Interface esp;
-DigitalOut usb1en(P3_8);
-#else
-#include "ESP8266Interface.h"
-ESP8266Interface esp(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
-#endif
-#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
-#include "EthernetInterface.h"
-EthernetInterface eth;
-#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
-#define MESH
-#include "NanostackInterface.h"
-LoWPANNDInterface mesh;
-#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
-#define MESH
-#include "NanostackInterface.h"
-ThreadInterface mesh;
-#endif
-
-#ifndef MESH
-// This is address to mbed Device Connector
-#define MBED_SERVER_ADDRESS "coap://api.connector.mbed.com:5684"
-#else
-// This is address to mbed Device Connector
-#define MBED_SERVER_ADDRESS "coaps://[2607:f0d0:2601:52::20]:5684"
-#endif
-
-Serial output(USBTX, USBRX);
+// easy-connect compliancy, it has 2 sets of wifi pins we have only one
+#define MBED_CONF_APP_ESP8266_TX MBED_CONF_APP_WIFI_TX
+#define MBED_CONF_APP_ESP8266_RX MBED_CONF_APP_WIFI_RX
+#include "easy-connect.h"
 
 // These are example resource values for the Device Object
 struct MbedClientDevice device = {
@@ -74,28 +68,10 @@
 // Instantiate the class which implements LWM2M Client API (from simpleclient.h)
 MbedClient mbed_client(device);
 
-
-#if(1)  //for zxing with camera
-InterruptIn unreg_button(USER_BUTTON0);
-#else
-// In case of K64F board , there is button resource available
-// to change resource value and unregister
-#ifdef TARGET_K64F
-// Set up Hardware interrupt button.
-InterruptIn obs_button(SW2);
-InterruptIn unreg_button(SW3);
-#else
-//In non K64F boards , set up a timer to simulate updating resource,
-// there is no functionality to unregister.
-Ticker timer;
-#endif
-#endif
-
 // LED Output
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
-
 /*
  * The Led contains one property (pattern) and a function (blink).
  * When the function blink is executed, the pattern is read, and the LED
@@ -131,13 +107,16 @@
         led_res->set_operation(M2MBase::POST_ALLOWED);
         // when a POST comes in, we want to execute the led_execute_callback
         led_res->set_execute_function(execute_callback(this, &LedResource::blink));
+
     }
 
     M2MObject* get_object() {
         return led_object;
     }
 
-    void blink(void *) {
+    void blink(void *argument) {
+
+
         // read the value of 'Pattern'
         M2MObjectInstance* inst = led_object->object_instance();
         M2MResource* res = inst->resource("5853");
@@ -158,7 +137,7 @@
         std::string s((char*)buffIn, sizeIn);
         std::vector<uint32_t>* v = new std::vector<uint32_t>;
 
-        output.printf("led_execute_callback pattern=%s\r\n", s.c_str());
+        printf("led_execute_callback pattern=%s\r\n", s.c_str());
 
         // our pattern is something like 500:200:500, so parse that
         std::size_t found = s.find_first_of(":");
@@ -171,16 +150,24 @@
                 v->push_back(atoi((const char*)s.c_str()));
             }
         }
-
-
-        // do_blink is called with the vector, and starting at -1
-        do_blink(v, cbuffIn, 0);
+        int position = 0;
+        while (1) {
+            do_blink(cbuffIn);
+            if (position >= v->size()) {
+                break;
+            }
+            // how long do we need to wait before the next blink?
+            Thread::wait(v->at(position));
+            position++;
+        }
+        free(buffIn);
+        free(cbuffIn);
+        delete v;
     }
 
 private:
     M2MObject* led_object;
-
-    void do_blink(std::vector<uint32_t>* pattern, uint8_t* color,  uint16_t position) {
+    void do_blink(uint8_t* color) {
         
         if (!strcmp((char *)color, "red")) {
             // blink the LED in red color
@@ -218,24 +205,9 @@
         else {
             // no operation
         }
-
-        // up the position, if we reached the end of the vector
-        if (position >= pattern->size()) {
-            // free memory, and exit this function
-            delete pattern;
-            return;
-        }
-
-        // how long do we need to wait before the next blink?
-        uint32_t delay_ms = pattern->at(position);
-
-        // Invoke same function after `delay_ms` (upping position)
-        Thread::wait(delay_ms);
-        do_blink(pattern, color, ++position);
     }
 };
 
-#if(1)  //for zxing with camera
 /*
  * The Zxing contains a function (send string).
  * When `handle_string_send` is executed, the string after decoding is sent.
@@ -253,7 +225,7 @@
         zxing_res->set_operation(M2MBase::GET_ALLOWED);
         // set initial value (all values in mbed Client are buffers)
         // to be able to read this data easily in the Connector console, we'll use a string
-        zxing_res->set_value((uint8_t*)"0", 1);        
+        zxing_res->set_value((uint8_t*)"0", 1);
     }
 
     ~ZxingResource() {
@@ -279,202 +251,73 @@
 private:
     M2MObject* zxing_object;
 };
-#else
-/*
- * The button contains one property (click count).
- * When `handle_button_click` is executed, the counter updates.
- */
-class ButtonResource {
-public:
-    ButtonResource(): counter(0) {
-        // create ObjectID with metadata tag of '3200', which is 'digital input'
-        btn_object = M2MInterfaceFactory::create_object("3200");
-        M2MObjectInstance* btn_inst = btn_object->create_object_instance();
-        // create resource with ID '5501', which is digital input counter
-        M2MResource* btn_res = btn_inst->create_dynamic_resource("5501", "Button",
-            M2MResourceInstance::INTEGER, true /* observable */);
-        // we can read this value
-        btn_res->set_operation(M2MBase::GET_ALLOWED);
-        // set initial value (all values in mbed Client are buffers)
-        // to be able to read this data easily in the Connector console, we'll use a string
-        btn_res->set_value((uint8_t*)"0", 1);        
-    }
 
-    ~ButtonResource() {
-    }
-
-    M2MObject* get_object() {
-        return btn_object;
-    }
-
-    /*
-     * When you press the button, we read the current value of the click counter
-     * from mbed Device Connector, then up the value with one.
-     */
-    void handle_button_click() {
-        M2MObjectInstance* inst = btn_object->object_instance();
-        M2MResource* res = inst->resource("5501");
-
-        // up counter
-        counter++;
-#ifdef TARGET_K64F
-        printf("handle_button_click, new value of counter is %d\r\n", counter);
-#else
-        printf("simulate button_click, new value of counter is %d\r\n", counter);
-#endif
-        // serialize the value of counter as a string, and tell connector
-        char buffer[20];
-        int size = sprintf(buffer,"%d",counter);
-        res->set_value((uint8_t*)buffer, size);
-    }
-
-private:
-    M2MObject* btn_object;
-    uint16_t counter;
-};
-#endif
-
-
-// Network interaction must be performed outside of interrupt context
-#if(1)  //for zxing with camera
 ZxingResource zxing_resource;
-#else
-Semaphore updates(0);
-#endif
-volatile bool registered = false;
-volatile bool clicked = false;
-osThreadId mainThread;
-
-void unregister() {
-    registered = false;
-#if(1)  //for zxing with camera
-#else
-    updates.release();
-#endif
-}
-
-#if(1)  //for zxing with camera
-#else
-void button_clicked() {
-    clicked = true;
-    updates.release();
-}
-#endif
-
-// debug printf function
-void trace_printer(const char* str) {
-    printf("%s\r\n", str);
-}
-
-// Status indication
-Ticker status_ticker;
-DigitalOut status_led(LED4);
-void blinky() { status_led = !status_led; }
-
-#if(1)  //for zxing with camera
-extern void zxing_init(void (*pfunc)(char * addr, int size));
-extern int zxing_loop();
 
 static void callback_zxing(char * addr, int size) {
     zxing_resource.handle_string_send(addr, size);
 }
-#endif
+
+static volatile bool registered;
+
+void unregister() {
+    registered = false;
+}
 
 // Entry point to the program
 int main() {
 
-#ifndef MBEDTLS_ENTROPY_HARDWARE_ALT
+    unsigned int seed;
+    size_t len;
 
-#ifdef MBEDTLS_TEST_NULL_ENTROPY
+#ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
+    // Used to randomize source port
+    mbedtls_hardware_poll(NULL, (unsigned char *) &seed, sizeof seed, &len);
+
+#elif defined MBEDTLS_TEST_NULL_ENTROPY
+
 #warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware."
+    // Used to randomize source port
+    mbedtls_null_entropy_poll( NULL,(unsigned char *) &seed, sizeof seed, &len);
 
 #else
 
 #error "This hardware does not have entropy, endpoint will not register to Connector.\
 You need to enable NULL ENTROPY for your application, but if this configuration change is made then no security is offered by mbed TLS.\
 Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app.json macros to register your endpoint."
-#endif
 
 #endif
-    status_ticker.attach_us(blinky, 250000);
 
+    srand(seed);
     // Keep track of the main thread
     mainThread = osThreadGetId();
+    printf("\nStarting mbed Client example in ");
 
-    // Sets the console baud-rate
-    output.baud(115200);
-
-    output.printf("Starting mbed Client example...\r\n");
+#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
+    printf("IPv6 mode\n");
+#else
+    printf("IPv4 mode\n");
+#endif
 
     mbed_trace_init();
-    mbed_trace_print_function_set(trace_printer);
 
-    NetworkInterface *network_interface = 0;
-    int connect_success = -1;
-#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI
-    output.printf("\n\rUsing WiFi \r\n");
-    output.printf("\n\rConnecting to WiFi..\r\n");
-#if(1) //bp3595
+#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI_BP3595
+    DigitalOut usb1en(P3_8);
     usb1en = 1;
     Thread::wait(5);
     usb1en = 0;
     Thread::wait(5);
-    connect_success = esp.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, MBED_CONF_APP_WIFI_SECURITY);
-#else
-    connect_success = esp.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD);
 #endif
-    network_interface = &esp;
-#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
-    output.printf("Using Ethernet\r\n");
-    connect_success = eth.connect();
-    network_interface = &eth;
-#endif
-#ifdef MESH
-    output.printf("Using Mesh\r\n");
-    output.printf("\n\rConnecting to Mesh..\r\n");
-    connect_success = mesh.connect();
-    network_interface = &mesh;
-#endif
-    if(connect_success == 0) {
-    output.printf("\n\rConnected to Network successfully\r\n");
-    } else {
-        output.printf("\n\rConnection to Network Failed %d! Exiting application....\r\n", connect_success);
-        return 0;
+
+    NetworkInterface* network = easy_connect(true);
+    if(network == NULL) {
+        printf("\nConnection to Network Failed - exiting application...\n");
+        return -1;
     }
-    const char *ip_addr = network_interface->get_ip_address();
-    if (ip_addr) {
-        output.printf("IP address %s\r\n", ip_addr);
-    } else {
-        output.printf("No IP address\r\n");
-    }
-
-#if(1)  //for zxing with camera
     LedResource led_resource;
 
-    // On press of USER_BUTTON0 button on GR-PEACH board, example application
-    // will call unregister API towards mbed Device Connector
-    unreg_button.fall(&unregister);
-#else
-    // we create our button and LED resources
-    ButtonResource button_resource;
-    LedResource led_resource;
-
-#ifdef TARGET_K64F
-    // On press of SW3 button on K64F board, example application
-    // will call unregister API towards mbed Device Connector
-    //unreg_button.fall(&mbed_client,&MbedClient::test_unregister);
-    unreg_button.fall(&unregister);
-
-    // Observation Button (SW2) press will send update of endpoint resource values to connector
-    obs_button.fall(&button_clicked);
-#else
-    // Send update of endpoint resource values to connector every 15 seconds periodically
-    timer.attach(&button_clicked, 15.0);
-#endif
-#endif
-
     // Create endpoint interface to manage register and unregister
-    mbed_client.create_interface(MBED_SERVER_ADDRESS, network_interface);
+    mbed_client.create_interface(MBED_SERVER_ADDRESS, network);
 
     // Create Objects of varying types, see simpleclient.h for more details on implementation.
     M2MSecurity* register_object = mbed_client.create_register_object(); // server object specifying connector info
@@ -485,26 +328,25 @@
 
     // Add objects to list
     object_list.push_back(device_object);
-#if(1)  //for zxing with camera
+    object_list.push_back(led_resource.get_object());
     object_list.push_back(zxing_resource.get_object());
-#else
-    object_list.push_back(button_resource.get_object());
-#endif
-    object_list.push_back(led_resource.get_object());
 
     // Set endpoint registration object
     mbed_client.set_register_object(register_object);
 
     // Register with mbed Device Connector
     mbed_client.test_register(register_object, object_list);
-    registered = true;
 
-#if(1)  //for zxing with camera
     zxing_init(&callback_zxing);
+
     Timer update_timer;
     update_timer.reset();
     update_timer.start();
 
+    registered = true;
+    InterruptIn unreg_button(USER_BUTTON0);
+    unreg_button.fall(&unregister);
+
     while (registered) {
         if (zxing_loop() == 0) {
             update_timer.reset();
@@ -516,23 +358,10 @@
         }
         Thread::wait(5);
     }
-#else
-    while (true) {
-        updates.wait(25000);
-        if(registered) {
-            if(!clicked) {
-                mbed_client.test_update_register();
-            }
-        }else {
-            break;
-        }
-        if(clicked) {
-           clicked = false;
-            button_resource.handle_button_click();
-        }
-    }
-#endif
 
     mbed_client.test_unregister();
-    status_ticker.detach();
 }
+
+#endif // MBED_CONF_APP_NETWORK_INTERFACE != NO_CONNECT
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-client.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-client/#56774e375bcc5b8b5f1d0bda3f7ebc2c09233bce
--- a/mbed-os.lib	Wed Oct 19 15:58:43 2016 +0900
+++ b/mbed-os.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/Osamu-Nakamura/mbed-os/#d055962f4721affb828d8631cada4fcf6ad65b04
+https://github.com/ARMmbed/mbed-os/#f4864dc6429e1ff5474111d4e0f6bee36a759b1c
--- a/mbed_app.json	Wed Oct 19 15:58:43 2016 +0900
+++ b/mbed_app.json	Tue Mar 28 11:02:34 2017 +0000
@@ -1,47 +1,53 @@
-{
-    "config": {
-        "network-interface":{
-            "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
-            "value": "ETHERNET"
-        },
-        "wifi-ssid": {
-            "help": "WiFi SSID",
-            "value": "\"SSID\""
-        },
-        "wifi-password": {
-            "help": "WiFi Password",
-            "value": "\"Password\""
-        },
-        "wifi-security": {
-            "help": "Type of encryption for connection",
-            "value": "NSAPI_SECURITY_WPA2"
-        },
-        "wifi-tx": {
-            "help": "TX pin for serial connection to external device",
-            "value": "D1"
-        },
-        "wifi-rx": {
-            "help": "RX pin for serial connection to external device",
-            "value": "D0"
-        }
-    },
-    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
-    "target_overrides": {
-        "*": {
-            "target.features_add": ["CLIENT", "COMMON_PAL"],
-            "mbed-client.reconnection-count": 3,
-            "mbed-client.reconnection-interval": 5
-        },
-        "NUCLEO_F401RE": {
-            "wifi-tx": "PA_11",
-            "wifi-rx": "PA_12"
-        },
-        "NUCLEO_F411RE": {
-            "wifi-tx": "PA_11",
-            "wifi-rx": "PA_12"
-        },
-        "RZ_A1H": {
-            "target.macros_add": ["MBEDTLS_TEST_NULL_ENTROPY", "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES"]
-        }
-    }
-}
+{
+    "config": {
+        "network-interface":{
+            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595, NO_CONNECT",
+            "value": "NO_CONNECT"
+        },
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"Password\""
+        },
+        "wifi-security":{
+            "help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
+            "value": "NSAPI_SECURITY_WPA_WPA2"
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "D1"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "D0"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+    "target_overrides": {
+        "*": {
+            "target.features_add": ["COMMON_PAL"],
+            "platform.stdio-baud-rate": 115200,
+            "platform.stdio-convert-newlines": true,
+            "mbed-trace.enable": 0
+        },
+        "NUCLEO_F401RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        },
+        "NUCLEO_F411RE": {
+            "wifi-tx": "PA_11",
+            "wifi-rx": "PA_12"
+        },
+        "RZ_A1H": {
+            "target.macros_add": ["MBEDTLS_TEST_NULL_ENTROPY", "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES"]
+        },
+        "UBLOX_EVK_ODIN_W2": {
+        "target.device_has_remove": ["EMAC"]
+        }
+    }
+}
+
+
--- a/mbedtls_mbed_client_config.h	Wed Oct 19 15:58:43 2016 +0900
+++ b/mbedtls_mbed_client_config.h	Tue Mar 28 11:02:34 2017 +0000
@@ -1,6 +1,15 @@
-/*
+/**
  *  Minimal configuration for using mbedtls as part of mbed-client
  *
+ *  NOTE! This is an optimized, minimal configuration for mbed Client.
+ *  We know it works with mbed Client but if you want to add more
+ *  services/communications to the application yourself - please ensure
+ *  you update this configuration accordingly. The default configuration
+ *  can be found from mbedTLS Github:
+ *
+ *  https://github.com/ARMmbed/mbedtls/blob/development/include/mbedtls/config.h
+ *
+ *
  *  Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
  *  SPDX-License-Identifier: Apache-2.0
  *
@@ -41,7 +50,6 @@
 #define MBEDTLS_ASN1_PARSE_C
 #define MBEDTLS_ASN1_WRITE_C
 #define MBEDTLS_BIGNUM_C
-#define MBEDTLS_CCM_C
 #define MBEDTLS_CIPHER_C
 #define MBEDTLS_CTR_DRBG_C
 #define MBEDTLS_ECP_C
@@ -59,22 +67,12 @@
 // XXX mbedclient needs these: mbedtls_x509_crt_free, mbedtls_x509_crt_init, mbedtls_x509_crt_parse
 #define MBEDTLS_X509_USE_C
 #define MBEDTLS_X509_CRT_PARSE_C
-// a bit wrong way to get mbedtls_ssl_conf_psk:
-// XXX: this should be ifdef'd out from client too
-#define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
 
 // XXX: clean these up!!
-#define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED
-#define MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED
-#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
 #define MBEDTLS_SHA512_C
 #define MBEDTLS_ECDH_C
 #define MBEDTLS_GCM_C
-#define MBEDTLS_CCM_C
 
-#define MBEDTLS_PKCS1_V15
-
-#define MBEDTLS_CIPHER_MODE_CBC
 #define MBEDTLS_ECDH_C
 #define MBEDTLS_ECDSA_C
 #define MBEDTLS_X509_CRT_PARSE_C
@@ -89,8 +87,6 @@
 // Remove selftesting and save 11KB of ROM
 #undef MBEDTLS_SELF_TEST
 
-#undef MBEDTLS_SSL_COOKIE_C
-
 // Reduces ROM size by 30 kB
 #undef MBEDTLS_ERROR_STRERROR_DUMMY
 #undef MBEDTLS_VERSION_FEATURES
@@ -101,7 +97,7 @@
 // dep of the previous
 #define MBEDTLS_BASE64_C
 
-// reduce IO buffer to save RAM, default is 16KB
+// Reduce IO buffer to save RAM, default is 16KB
 #define MBEDTLS_SSL_MAX_CONTENT_LEN 2048
 
 // define to save 8KB RAM at the expense of ROM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pal.lib	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/pal/#4e46c0ea870631bb5bec3e4aa9fd7eebf3db21f0
--- a/simpleclient.h	Wed Oct 19 15:58:43 2016 +0900
+++ b/simpleclient.h	Tue Mar 28 11:02:34 2017 +0000
@@ -25,11 +25,44 @@
 #include "mbed-client/m2mobjectinstance.h"
 #include "mbed-client/m2mresource.h"
 #include "mbed-client/m2mconfig.h"
+#include "mbed-client/m2mblockmessage.h"
 #include "security.h"
 #include "mbed.h"
 
-//Select binding mode: UDP or TCP
-M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP;
+#define ETHERNET        1
+#define WIFI            2
+#define MESH_LOWPAN_ND  3
+#define MESH_THREAD     4
+#define ATMEL           5
+#define MCR20           6
+
+#define STRINGIFY(s) #s
+
+// Check if using mesh networking, define helper
+#if MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
+    #define MESH
+#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
+    #define MESH
+#endif
+
+#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
+    // Mesh is always IPV6 - also WiFi and ETH can be IPV6 if IPV6 is enabled
+    M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv6;
+#else
+    // Everything else - we assume it's IPv4
+    M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv4;
+#endif
+
+//Select binding mode: UDP or TCP -- note - Mesh networking is IPv6 UDP ONLY
+#ifdef MESH
+    M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP;
+#else
+    // WiFi or Ethernet supports both - TCP by default to avoid
+    // NAT problems, but UDP will also work - IF you configure
+    // your network right.
+    M2MInterface::BindingMode SOCKET_MODE = M2MInterface::TCP;
+#endif
+
 
 // MBED_DOMAIN and MBED_ENDPOINT_NAME come
 // from the security.h file copied from connector.mbed.com
@@ -89,10 +122,9 @@
     */
     void create_interface(const char *server_address,
                           void *handler=NULL) {
-	// Randomizing listening port for Certificate mode connectivity
+    // Randomizing listening port for Certificate mode connectivity
     _server_address = server_address;
-	srand(time(NULL));
-	uint16_t port = rand() % 65535 + 12345;
+    uint16_t port = 0; // Network interface will randomize with port 0
 
     // create mDS interface object, this is the base object everything else attaches to
     _interface = M2MInterfaceFactory::create_interface(*this,
@@ -102,7 +134,7 @@
                                                       port,                     // listen port
                                                       MBED_DOMAIN,              // domain string
                                                       SOCKET_MODE,              // binding mode
-                                                      M2MInterface::LwIP_IPv4,  // network stack
+                                                      NETWORK_STACK,            // network stack
                                                       "");                      // context address string
     const char *binding_mode = (SOCKET_MODE == M2MInterface::UDP) ? "UDP" : "TCP";
     printf("\r\nSOCKET_MODE : %s\r\n", binding_mode);
@@ -142,9 +174,9 @@
             // Add ResourceID's and values to the security ObjectID/ObjectInstance
             security->set_resource_value(M2MSecurity::M2MServerUri, _server_address);
             security->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::Certificate);
-            security->set_resource_value(M2MSecurity::ServerPublicKey, SERVER_CERT, sizeof(SERVER_CERT));
-            security->set_resource_value(M2MSecurity::PublicKey, CERT, sizeof(CERT));
-            security->set_resource_value(M2MSecurity::Secretkey, KEY, sizeof(KEY));
+            security->set_resource_value(M2MSecurity::ServerPublicKey, SERVER_CERT, sizeof(SERVER_CERT) - 1);
+            security->set_resource_value(M2MSecurity::PublicKey, CERT, sizeof(CERT) - 1);
+            security->set_resource_value(M2MSecurity::Secretkey, KEY, sizeof(KEY) - 1);
         }
         return security;
     }
@@ -214,7 +246,7 @@
     void object_unregistered(M2MSecurity */*server_object*/){
         trace_printer("Unregistered Object Successfully");
         _unregistered = true;
-        _registered = false;               
+        _registered = false;
     }
 
     /*
@@ -284,10 +316,11 @@
     */
     void value_updated(M2MBase *base, M2MBase::BaseType type) {
         printf("\r\nPUT Request Received!");
-        printf("\r\nName :'%s', \r\nType : '%d' (0 for Object, 1 for Resource), \r\nType : '%s'\r\n",
-               base->name().c_str(),
+        printf("\r\nName :'%s', \r\nPath : '%s', \r\nType : '%d' (0 for Object, 1 for Resource), \r\nType : '%s'\r\n",
+               base->name(),
+               base->uri_path(),
                type,
-               base->resource_type().c_str()
+               base->resource_type()
                );
     }
 
--- a/zxing_lib/ImageReaderSource.h	Wed Oct 19 15:58:43 2016 +0900
+++ b/zxing_lib/ImageReaderSource.h	Tue Mar 28 11:02:34 2017 +0000
@@ -71,7 +71,7 @@
   zxing::ArrayRef<char> getMatrix() const;
 };
 
-extern int ex_decode(uint8_t* buf, int buf_size, int width, int height, vector<Ref<Result> > * results);
+extern int ex_decode(uint8_t* buf, int buf_size, int width, int height, vector<Ref<Result> > * results, DecodeHints &hints);
 
 
 #endif /* __IMAGE_READER_SOURCE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing_config.h	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,21 @@
+
+/**** User Selection *********/
+
+//#define ZXING_EXCLUDE_1DCODE                      /* define : 1D barcodes can not be scanned */
+#undef ZXING_EXCLUDE_1DCODE                         /* undef  : 1D barcodes can be scanned */
+                                                    
+//#define ZXING_EXCLUDE_QRCODE                      /* define : QR-code can not be scanned */
+#undef ZXING_EXCLUDE_QRCODE                         /* undef  : QR-code can be scanned */
+                                                    
+//#define ZXING_EXCLUDE_MATRIX                      /* define : Matrix can not be scanned */
+#undef ZXING_EXCLUDE_MATRIX                         /* undef  : Matrix can be scanned */
+                                                    
+//#define ZXING_EXCLUDE_AZTEC                       /* define : Aztec can not be scanned */
+#undef ZXING_EXCLUDE_AZTEC                          /* undef  : Aztec can be scanned */
+                                                    
+//#define ZXING_EXCLUDE_PDF417                      /* define : PDF417 can not be scanned */
+#undef ZXING_EXCLUDE_PDF417                         /* undef  : PDF417 can be scanned */
+
+//#define ZXING_MULTI_QUADRANT                      /* define : Zxing can multi decode */
+#undef ZXING_MULTI_QUADRANT                         /* undef  : Zxing can not multi decode */
+
Binary file zxing_lib/zxing_lib.ar has changed
--- a/zxing_main.cpp	Wed Oct 19 15:58:43 2016 +0900
+++ b/zxing_main.cpp	Tue Mar 28 11:02:34 2017 +0000
@@ -1,28 +1,24 @@
-
-#include <vector>
 
 #include "mbed.h"
 #include "rtos.h"
 #include "DisplayBace.h"
 #include "ImageReaderSource.h"
-#include "DisplayApp.h"
-#include "AsciiFont.h"
 
 #define VIDEO_CVBS             (0)                 /* Analog  Video Signal */
 #define VIDEO_CMOS_CAMERA      (1)                 /* Digital Video Signal */
-#define VIDEO_RGB888           (1)
 
 /**** User Selection *********/
 /** Camera setting **/
 #define VIDEO_INPUT_METHOD     (VIDEO_CMOS_CAMERA) /* Select  VIDEO_CVBS or VIDEO_CMOS_CAMERA                       */
-#define VIDEO_INPUT_FORMAT     (VIDEO_RGB888)      /* Select  VIDEO_RGB888                                          */
 #define USE_VIDEO_CH           (0)                 /* Select  0 or 1            If selecting VIDEO_CMOS_CAMERA, should be 0.)               */
 #define VIDEO_PAL              (0)                 /* Select  0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */
 /** LCD setting **/
 #define LCD_ONOFF              (1)                 /* Select  0(without LCD) or 1(with LCD) */
-#if LCD_ONOFF
 #define LCD_TYPE               (0)                 /* Select  0(4.3inch) or 1(7.1inch) */
-#endif
+/** JPEG out setting **/
+#define JPEG_SEND              (0)                 /* Select  0(JPEG images are not output to PC) or 1(JPEG images are output to PC on USB(CDC) for focusing the camera) */
+/** Decode hints **/
+#define DECODE_HINTS           (DecodeHints::ONED_HINT | DecodeHints::QR_CODE_HINT | DecodeHints::DATA_MATRIX_HINT | DecodeHints::AZTEC_HINT)
 /*****************************/
 
 #if LCD_ONOFF
@@ -32,6 +28,12 @@
 #else
   #include "LCD_shield_config_7_1inch.h"
 #endif
+  #include "AsciiFont.h"
+#endif
+
+#ifdef JPEG_SEND
+  #include "JPEG_Converter.h"
+  #include "DisplayApp.h"
 #endif
 
 /** Video and Grapics (GRAPHICS_LAYER_0) parameter **/
@@ -52,83 +54,48 @@
 #endif
 
 /* Video input */
-#define VIDEO_FORMAT           (DisplayBase::VIDEO_FORMAT_RGB888)
-#define GRAPHICS_FORMAT        (DisplayBase::GRAPHICS_FORMAT_RGB888)
-#define WR_RD_WRSWA            (DisplayBase::WR_RD_WRSWA_32BIT)
+#define VIDEO_FORMAT           (DisplayBase::VIDEO_FORMAT_YCBCR422)
+#define GRAPHICS_FORMAT        (DisplayBase::GRAPHICS_FORMAT_YCBCR422)
+#define WR_RD_WRSWA            (DisplayBase::WR_RD_WRSWA_16BIT)
+#define FRAME_BUFFER_BYTE_PER_PIXEL   (2u)
+
+#if VIDEO_INPUT_METHOD == VIDEO_CVBS
+  #define WAIT_VFIELD_CNT      (2)
+#else
+  #define WAIT_VFIELD_CNT      (1)
+#endif
 
 /* The size of the video input */
 #if ((LCD_ONOFF) && (LCD_TYPE == 0))
-  #define VIDEO_PIXEL_HW                LCD_PIXEL_WIDTH
-  #define VIDEO_PIXEL_VW                LCD_PIXEL_HEIGHT
+  #define VIDEO_PIXEL_HW       LCD_PIXEL_WIDTH
+  #define VIDEO_PIXEL_VW       LCD_PIXEL_HEIGHT
 #else
-  #define VIDEO_PIXEL_HW                (640)  /* VGA */
-  #define VIDEO_PIXEL_VW                (480)  /* VGA */
+  #define VIDEO_PIXEL_HW       (640)  /* VGA */
+  #define VIDEO_PIXEL_VW       (480)  /* VGA */
 #endif
 
 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
     in accordance with the frame buffer burst transfer mode. */
 /* FRAME BUFFER Parameter GRAPHICS_LAYER_0 */
-#define FRAME_BUFFER_NUM              (2u)
-#define FRAME_BUFFER_BYTE_PER_PIXEL   (4u)
-#define FRAME_BUFFER_STRIDE           (((VIDEO_PIXEL_HW * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
-
-#if LCD_ONOFF
-#define VIDEO_PIXEL_HW_STR              (VIDEO_PIXEL_HW - 64)
-#define VIDEO_PIXEL_VW_STR              (VIDEO_PIXEL_VW - 64)
-#define FRAME_BUFFER_BYTE_PER_PIXEL_STR (2u)
-#define FRAME_BUFFER_STRIDE_STR         (((VIDEO_PIXEL_HW_STR * FRAME_BUFFER_BYTE_PER_PIXEL_STR) + 31u) & ~31u)
-#endif
+#define FRAME_BUFFER_STRIDE    (((VIDEO_PIXEL_HW * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
 
 static DisplayBase Display;
-static DisplayApp  display_app;
 static Timer decode_timer;
-#if LCD_ONOFF
-static DigitalOut  lcd_pwon(P7_15);
-static DigitalOut  lcd_blon(P8_1);
-static PwmOut      lcd_cntrst(P8_15);
-#endif
 
 /* 32 bytes aligned */
-static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW]__attribute((aligned(32)));
-static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW]__attribute((aligned(32)));
-#if LCD_ONOFF
-static uint8_t user_frame_buffer_string[FRAME_BUFFER_STRIDE_STR * VIDEO_PIXEL_VW_STR]__attribute((aligned(32)));
-static AsciiFont ascii_font(user_frame_buffer_string, VIDEO_PIXEL_HW_STR, VIDEO_PIXEL_VW_STR, FRAME_BUFFER_STRIDE_STR, FRAME_BUFFER_BYTE_PER_PIXEL_STR);
-static bool      string_draw;
-#endif
-static uint8_t * decode_buffer = user_frame_buffer0;
-static uint8_t * FrameBufferTbl[FRAME_BUFFER_NUM] = {user_frame_buffer0, user_frame_buffer1};
+static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW]__attribute((section("NC_BSS"),aligned(32)));
+
 static volatile int32_t vfield_count = 0;
-static int write_buff_num = 0;
 static bool graphics_init_end = false;
 static int decode_wait_time = 0;
 static void (*p_callback_func)(char * addr, int size);
 
-/****** cache control ******/
-static void dcache_clean(void * p_buf, uint32_t size) {
-    uint32_t start_addr = (uint32_t)p_buf & 0xFFFFFFE0;
-    uint32_t end_addr   = (uint32_t)p_buf + size;
-    uint32_t addr;
-
-    /* Data cache clean */
-    for (addr = start_addr; addr < end_addr; addr += 0x20) {
-        __v7_clean_dcache_mva((void *)addr);
-    }
-}
-
-static void dcache_invalid(void * p_buf, uint32_t size){
-    uint32_t start_addr = (uint32_t)p_buf & 0xFFFFFFE0;
-    uint32_t end_addr   = (uint32_t)p_buf + size;
-    uint32_t addr;
-
-    /* Data cache invalid */
-    for (addr = start_addr; addr < end_addr; addr += 0x20) {
-        __v7_inv_dcache_mva((void *)addr);
-    }
-}
-
 #if LCD_ONOFF
 /****** LCD ******/
+static DigitalOut  lcd_pwon(P7_15);
+static DigitalOut  lcd_blon(P8_1);
+static PwmOut      lcd_cntrst(P8_15);
+
 static void Init_LCD_Display(void) {
     DisplayBase::graphics_error_t error;
     DisplayBase::lcd_config_t lcd_config;
@@ -172,7 +139,120 @@
     );
     Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
 }
-#endif
+
+#define VIDEO_PIXEL_HW_STR              (VIDEO_PIXEL_HW - 64)
+#define VIDEO_PIXEL_VW_STR              (VIDEO_PIXEL_VW - 64)
+#define FRAME_BUFFER_BYTE_PER_PIXEL_STR (2u)
+#define FRAME_BUFFER_STRIDE_STR         (((VIDEO_PIXEL_HW_STR * FRAME_BUFFER_BYTE_PER_PIXEL_STR) + 31u) & ~31u)
+
+static uint8_t user_frame_buffer_string[FRAME_BUFFER_STRIDE_STR * VIDEO_PIXEL_VW_STR]__attribute((section("NC_BSS"),aligned(32)));
+static AsciiFont ascii_font(user_frame_buffer_string, VIDEO_PIXEL_HW_STR, VIDEO_PIXEL_VW_STR, FRAME_BUFFER_STRIDE_STR, FRAME_BUFFER_BYTE_PER_PIXEL_STR);
+static bool      string_draw;
+
+static void decode_string_init(void) {
+    DisplayBase::rect_t rect;
+
+    /* The layer by which the touch panel location is drawn */
+    ascii_font.Erase(0x00000000);  /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
+    rect.vs = 32;
+    rect.vw = VIDEO_PIXEL_VW_STR;
+    rect.hs = 32;
+    rect.hw = VIDEO_PIXEL_HW_STR;
+    Display.Graphics_Read_Setting(
+        DisplayBase::GRAPHICS_LAYER_1,
+        (void *)user_frame_buffer_string,
+        FRAME_BUFFER_STRIDE_STR,
+        DisplayBase::GRAPHICS_FORMAT_ARGB4444,
+        DisplayBase::WR_RD_WRSWA_32_16BIT,
+        &rect
+    );
+    Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_1);
+    string_draw = false;
+}
+
+static void decode_string_disp(char ** decode_str) {
+    if ((decode_str != NULL) && (*decode_str != NULL)) {
+        /* Drow string */
+        ascii_font.Erase(0x00000090);  /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
+        int rest_size = strlen(*decode_str);
+        int draw_idx = 0;
+        int draw_size;
+        int draw_line = 0;
+
+        while (rest_size > 0) {
+            draw_size = ascii_font.DrawStr(*decode_str + draw_idx, 6, 5 + (18 * draw_line), 0x0000ffff, 2);
+            if (draw_size <= 0) {
+                break;
+            }
+            rest_size -= draw_size;
+            draw_idx += draw_size;
+            draw_line++;
+        }
+        string_draw = true;
+    } else {
+        if (string_draw != false) {
+            /* Clear string */
+            ascii_font.Erase(0x00000000);  /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
+            string_draw = false;
+        }
+    }
+}
+#endif // LCD_ONOFF
+
+#ifdef JPEG_SEND
+/****** Jpeg Send ******/
+#define JPEG_ENC_MAX_SIZE      (1024 * 63)
+#define JPEG_SIGNAL_CAP_COMP   (1L)
+
+#define JPEGSEND_STB           (0)
+#define JPEGSEND_ENC           (1)
+
+static Thread jpegsendTask(osPriorityAboveNormal, 2048);
+static DisplayApp  display_app;
+static uint8_t JpegBuffer[JPEG_ENC_MAX_SIZE]__attribute((section("NC_BSS"),aligned(8)));  //8 bytes aligned!;
+volatile static uint32_t jpegsend_status = JPEGSEND_STB;
+
+static void jpegsendTask_main( void ) {
+    JPEG_Converter Jcu;
+    size_t jcu_encode_size;
+
+    while (1) {
+        Thread::signal_wait(JPEG_SIGNAL_CAP_COMP, 80);
+        jpegsend_status = JPEGSEND_ENC;
+
+        /* JPEG Enc Start */
+        JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
+        JPEG_Converter::encode_options_t   encode_options;
+        bitmap_buff_info.width              = VIDEO_PIXEL_HW;
+        bitmap_buff_info.height             = VIDEO_PIXEL_VW;
+        bitmap_buff_info.format             = JPEG_Converter::WR_RD_YCbCr422;
+        bitmap_buff_info.buffer_address     = (void *)user_frame_buffer0;
+        encode_options.encode_buff_size     = sizeof(JpegBuffer);
+        encode_options.p_EncodeCallBackFunc = NULL;
+        encode_options.input_swapsetting    = JPEG_Converter::WR_RD_WRSWA_16_8BIT;
+        jcu_encode_size = 0;
+        if (Jcu.encode(&bitmap_buff_info, JpegBuffer, &jcu_encode_size, &encode_options) != JPEG_Converter::JPEG_CONV_OK) {
+            jcu_encode_size = 0;
+        }
+
+        /* JPEG Data Send */
+        if ((jcu_encode_size > 256) && (jcu_encode_size < JPEG_ENC_MAX_SIZE)) {
+            display_app.SendJpeg(JpegBuffer, jcu_encode_size);
+        }
+        jpegsend_status = JPEGSEND_STB;
+    }
+}
+
+static void jpegsendTask_init( void ) {
+    jpegsendTask.start(jpegsendTask_main);
+}
+
+static void jpegsend_cap_comp( void ) {
+    if (jpegsend_status == JPEGSEND_STB) {
+        jpegsendTask.signal_set(JPEG_SIGNAL_CAP_COMP);
+    }
+}
+#endif // JPEG_SEND
 
 /****** Video ******/
 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
@@ -180,6 +260,9 @@
     if (vfield_count > 0) {
         vfield_count--;
     }
+#ifdef JPEG_SEND
+    jpegsend_cap_comp();
+#endif // JPEG_SEND
 }
 
 static void Wait_Vfield(const int32_t wait_count) {
@@ -310,49 +393,31 @@
 /****** zxing_init ******/
 void zxing_init(void (*pfunc)(char * addr, int size)) {
 
+#ifdef JPEG_SEND
+    jpegsendTask_init();
+#endif // JPEG_SEND
 #if LCD_ONOFF
     /* Initialization of LCD */
     Init_LCD_Display();    /* When using LCD, please call before than Init_Video(). */
-#endif
+#endif // LCD_ONOFF
     /* Initialization of Video */
     Init_Video();
 
     /* Initialization memory */
-    for (int i = 0; i < FRAME_BUFFER_NUM; i++) {
-        memset(FrameBufferTbl[i], 0, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW));
-        dcache_clean(FrameBufferTbl[i], (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW));
-    }
+    memset(user_frame_buffer0, 0, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW));
 
     /* Start of Video */
-    Start_Video(FrameBufferTbl[write_buff_num]);
+    Start_Video(user_frame_buffer0);
     /* Wait for first video drawing */
-    Wait_Vfield(2);
+    Wait_Vfield(WAIT_VFIELD_CNT);
 #if LCD_ONOFF
-    DisplayBase::rect_t rect;
-
-    /* The layer by which the touch panel location is drawn */
-    ascii_font.Erase(0x00000000);  /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
-    dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
-    rect.vs = 32;
-    rect.vw = VIDEO_PIXEL_VW_STR;
-    rect.hs = 32;
-    rect.hw = VIDEO_PIXEL_HW_STR;
-    Display.Graphics_Read_Setting(
-        DisplayBase::GRAPHICS_LAYER_1,
-        (void *)user_frame_buffer_string,
-        FRAME_BUFFER_STRIDE_STR,
-        DisplayBase::GRAPHICS_FORMAT_ARGB4444,
-        DisplayBase::WR_RD_WRSWA_32_16BIT,
-        &rect
-    );
-    Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_1);
-    string_draw = false;
+    decode_string_init();
     /* Start of LCD */
-    Start_LCD_Display(FrameBufferTbl[write_buff_num]);
+    Start_LCD_Display(user_frame_buffer0);
     /* Backlight on */
     Thread::wait(200);
     lcd_cntrst.write(1.0);
-#endif
+#endif // LCD_ONOFF
     p_callback_func = pfunc;
     decode_timer.reset();
     decode_timer.start();
@@ -363,72 +428,30 @@
     DisplayBase::graphics_error_t error;
     int decode_result = -1;
     vector<Ref<Result> > results;
+    char ** decode_str = NULL;
 
-    decode_buffer = FrameBufferTbl[write_buff_num];
-    write_buff_num++;
-    if (write_buff_num >= FRAME_BUFFER_NUM) {
-        write_buff_num = 0;
-    }
-    /* Change video buffer */
-    error = Display.Video_Write_Change(VIDEO_INPUT_CH, FrameBufferTbl[write_buff_num], FRAME_BUFFER_STRIDE);
-    if (error != DisplayBase::GRAPHICS_OK) {
-        printf("Line %d, error %d\n", __LINE__, error);
-        mbed_die();
-    }
-    Wait_Vfield(2);
-#if LCD_ONOFF
-    /* Change LCD buffer */
-    Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, (void *)FrameBufferTbl[write_buff_num]);
-#endif
-    dcache_invalid(decode_buffer, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW));
+    Wait_Vfield(WAIT_VFIELD_CNT);
     /* Decode barcode image */
     if (decode_timer.read_ms() >= decode_wait_time) {
         decode_timer.reset();
-        decode_result = ex_decode(decode_buffer, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW), VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, &results);
+        DecodeHints hints(DECODE_HINTS);
+        hints.setTryHarder(false);
+        decode_result = ex_decode(user_frame_buffer0, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW), VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, &results, hints);
         if (decode_result == 0) {
-            char ** decode_str;
-            int     size;
-
             decode_str = (char **)&(results[0]->getText()->getText());
-            size = strlen(*decode_str);
+            int size = strlen(*decode_str);
             if (p_callback_func != NULL) {
                 p_callback_func(*decode_str, size);
             }
-#if LCD_ONOFF
-            /* Drow string */
-            ascii_font.Erase(0x00000090);  /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
-            int rest_size = strlen(*decode_str);
-            int draw_idx = 0;
-            int draw_size;
-            int draw_line = 0;
-
-            while (rest_size > 0) {
-                draw_size = ascii_font.DrawStr(*decode_str + draw_idx, 6, 5 + (18 * draw_line), 0x0000ffff, 2);
-                if (draw_size <= 0) {
-                    break;
-                }
-                rest_size -= draw_size;
-                draw_idx += draw_size;
-                draw_line++;
-            }
-           
-            dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
-            string_draw = true;
-#endif
             decode_wait_time = 500;
         } else {
-#if LCD_ONOFF
-            if (string_draw != false) {
-                /* Clear string */
-                ascii_font.Erase(0x00000000);  /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
-                dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
-                string_draw = false;
-            }
-#endif
             decode_wait_time = 10;
         }
+#if LCD_ONOFF
+        decode_string_disp(decode_str);
+#endif // LCD_ONOFF
     }
-    display_app.SendRgb888(decode_buffer, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW);
 
     return decode_result;
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_main.h	Tue Mar 28 11:02:34 2017 +0000
@@ -0,0 +1,9 @@
+
+#ifndef ZXING_MAIN_H
+#define ZXING_MAIN_H
+
+extern void zxing_init(void (*pfunc)(char * addr, int size));
+extern int zxing_loop();
+
+#endif
+