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:
<>
Date:
Thu Oct 06 18:00:30 2016 +0900
Child:
1:5d3134f9efae
Commit message:
Initial Commit

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
AsciiFont.lib Show annotated file Show diff for this revision Revisions of this file
DisplayApp.lib Show annotated file Show diff for this revision Revisions of this file
GR-PEACH_video.lib Show annotated file Show diff for this revision Revisions of this file
GW_Binary/gateway6LoWPANDynamic.bin Show annotated file Show diff for this revision Revisions of this file
GW_Binary/gateway6LoWPANStatic.bin Show annotated file Show diff for this revision Revisions of this file
GW_Binary/gatewayThreadDynamic.bin Show annotated file Show diff for this revision Revisions of this file
GW_Binary/gatewayThreadStatic.bin 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
LICENSE Show annotated file Show diff for this revision Revisions of this file
LWIPBP3595Interface_for_mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
apache-2.0.txt Show annotated file Show diff for this revision Revisions of this file
clicks.png Show annotated file Show diff for this revision Revisions of this file
docs/img/Radio_Identifications.png Show annotated file Show diff for this revision Revisions of this file
docs/img/Radio_Identifications_GW.png Show annotated file Show diff for this revision Revisions of this file
docs/radio_module_identify.md Show annotated file Show diff for this revision Revisions of this file
esp8266-driver.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp 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
mbed_client_config.h 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
security.h 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.png 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/BarcodeFormat.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/Binarizer.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/BinaryBitmap.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/DecodeHints.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/Exception.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/LuminanceSource.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/MultiFormatReader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/Reader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/ReaderException.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/Result.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/ResultPoint.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/ResultPointCallback.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/ZXing.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/Array.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/BitArray.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/BitMatrix.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/Counted.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/DecoderResult.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/GlobalHistogramBinarizer.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/HybridBinarizer.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/IllegalArgumentException.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/Str.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/reedsolomon/GenericGF.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/reedsolomon/GenericGFPoly.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/common/reedsolomon/ReedSolomonDecoder.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/multi/ByQuadrantReader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/multi/GenericMultipleBarcodeReader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/multi/MultipleBarcodeReader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/multi/qrcode/QRCodeMultiReader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/qrcode/QRCodeReader.h Show annotated file Show diff for this revision Revisions of this file
zxing_lib/zxing/qrcode/decoder/Decoder.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,34 @@
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+yotta_modules/
+yotta_targets/
+build/
+.yotta.json
+source/security.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AsciiFont.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Renesas/code/AsciiFont/#0d8bc371d109
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DisplayApp.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/dkato/code/DisplayApp/#b7ffe5216cd7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GR-PEACH_video.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Renesas/code/GR-PEACH_video/#aeefe5171463
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/LCD_shield_config.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/dkato/code/LCD_shield_config/#5bc6a60b8ff5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,2 @@
+Unless specifically indicated otherwise in a file, files are licensed
+under the Apache 2.0 license, as can be found in: apache-2.0.txt
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LWIPBP3595Interface_for_mbed-os.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/dkato/code/LWIPBP3595Interface_STA_for_mbed-os/#590c87b7dcc2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,192 @@
+# Getting started with mbed Client on mbed OS
+
+This is the mbed Client example for mbed OS (we also have one for [Linux](https://github.com/ARMmbed/mbed-client-linux-example)). It demonstrates how to register a device with mbed Device Connector, how to read and write values, and how to deregister. If you are unfamiliar with mbed Device Connector, we recommend that you read [the introduction to the data model](https://docs.mbed.com/docs/mbed-device-connector-web-interfaces/en/latest/#the-mbed-device-connector-data-model) first.
+
+The application:
+
+* Connects to network with WiFi or Ethernet.
+* Registers with mbed Device Connector.
+* Gives mbed Device Connector access to its resources (read and write).
+* Records the number of clicks on the device’s button and sends the number to mbed Device Connector.
+* Lets you control the blink pattern of the LED on the device (through mbed Device Connector).
+
+## Required hardware
+
+* [Renesas GR-PEACH](https://developer.mbed.org/platforms/Renesas-GR-PEACH/).
+* 1-2 micro-USB cables.
+* Ethernet cable and connection to the internet.
+
+## Requirements for Renesas GR-PEACH
+* 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"],
+```
+
+## Required software
+
+* [ARM mbed account](https://developer.mbed.org/account/login/?next=/).
+* [mbed-cli](https://github.com/ARMmbed/mbed-cli) - to build the example programs. To learn how to build mbed OS applications with mbed-cli, see [the user guide](https://github.com/ARMmbed/mbed-cli/blob/master/README.md).
+* [Serial port monitor](https://developer.mbed.org/handbook/SerialPC#host-interface-and-terminal-applications).
+
+## Application setup
+
+To configure the example application, please:
+
+1. [Select the connection type](#connection-type).
+1. [Set the client credentials](#client-credentials).
+1. [Change Ethernet settings](#ethernet-settings).
+1. [Change Wi-Fi settings](#wi-fi-settings).
+1. [Set up an IP address](#ip-address-setup). This step is optional.
+1. [Change the socket type](#changing-socket-type). This step is optional.
+
+### 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:
+
+```json
+    "network-interface": {
+        "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD.",
+        "value": "MESH_LOWPAN_ND"
+    }
+```
+
+### Client credentials
+
+To register the application to the Connector service, you need to create and set the client side certificate.
+
+1. Go to [mbed Device Connector](https://connector.mbed.com) and log in with your mbed account.
+1. On mbed Device Connector, go to [My Devices > Security credentials](https://connector.mbed.com/#credentials) and click the **Get my device security credentials** button to get new credentials for your device.
+1. Replace the contents in `security.h` of this project's directory with content copied above.
+
+### Ethernet settings
+
+For running the example application using Ethernet, you need:
+
+- An Ethernet cable.
+- An Ethernet connection to the internet.
+
+### Wi-Fi settings (BP3595)
+
+The example application uses BP3595 WiFi Interface for managing the wireless connectivity. To run this application using WiFi, you need:
+
+1. An [BP3595](https://developer.mbed.org/components/BP3595-for-GR-PEACH/) WiFi module
+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"
+    }
+```
+
+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.
+```json
+    "wifi-ssid": {
+        "help": "WiFi SSID",
+        "value": "\"SSID\""
+    },
+    "wifi-password": {
+        "help": "WiFi Password",
+        "value": "\"Password\""
+    }
+```
+
+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.
+```json
+    "wifi-security": {
+        "help": "Type of encryption for connection",
+        "value": "NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WEP"
+    }
+```
+
+Short the jumper JP1 of [Audio Camera Shield](https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield) to supply the power to BP3595.
+
+<span class="tips">**TODO:** Need to clarify when Audio Camera Shield is NOT available.</span>
+
+### 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.
+
+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.
+
+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. 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>
+
+## Building the example
+
+To build the example application:
+
+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.
+
+## Monitoring the application
+
+The application prints debug messages over the serial port, so you can monitor its activity with a serial port monitor. The application uses baud rate 115200.
+
+<span class="notes">**Note:** Instructions to set this up are located [here](https://developer.mbed.org/handbook/SerialPC#host-interface-and-terminal-applications).</span>
+
+
+```
+Starting mbed Client example...
+Using <Network Interface>
+
+Connected to Network successfully
+IP address xxx.xxx.xxx.xxx
+
+SOCKET_MODE : UDP
+Connecting to coap://api.connector.mbed.com:5684
+
+```
+
+<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>
+
+When the barcode data is successfully decoded, you should see the decoded string.
+
+## Testing the application
+
+1. Flash the application.
+1. Verify that the registration succeeded. You should see `Registered object successfully!` printed to the serial port.
+1. On mbed Device Connector, go to [My devices > Connected devices](https://connector.mbed.com/#endpoints). Your device should be listed here.
+1. Input the barcode data via camera. (If the decode is successfully carried out, decoded string should be uploaded onto mbed Device Connector)
+1. Go to [Device Connector > API Console](https://connector.mbed.com/#console).
+1. Enter `https://api.connector.mbed.com/endpoints/DEVICE_NAME/3202/0/5700` in the URI field and click **TEST API**. Replace `DEVICE_NAME` with your actual endpoint name. The device name can be found in the `security.h` file, see variable `MBED_ENDPOINT_NAME` or it can be found from the traces [Monitoring the application](https://github.com/ARMmbed/mbed-os-example-client#monitoring-the-application).
+1. Decoded string is shown.
+1. Press the `SW3` button to unregister from mbed Device Connector. You should see `Unregistered Object Successfully` printed to the serial port and the LED starts blinking. This will also stop your application. Press the `RESET` button to run the program again.
+
+![Decoded String, as shown by the API Console](zxing.png)
+
+<span class="tips">**Tip:** If you get an error, for example `Server Response: 410 (Gone)`, clear your browser's cache, log out, and log back in.</span>
+
+<span class="notes">**Note:** Only GET methods can be executed through [Device Connector > API Console](https://connector.mbed.com/#console). For other methods check the [mbed Device Connector Quick Start](https://github.com/ARMmbed/mbed-connector-api-node-quickstart).
+
+### 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):
+
+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).
+
+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/USBDevice.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/mbed_official/code/USBDevice/#01321bd6ff89
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apache-2.0.txt	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,56 @@
+
+
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+    You must give any other recipients of the Work or Derivative Works a copy of this License; and
+    You must cause any modified files to carry prominent notices stating that You changed the files; and
+    You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+    If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+
+    You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file
Binary file clicks.png has changed
Binary file docs/img/Radio_Identifications.png has changed
Binary file docs/img/Radio_Identifications_GW.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/radio_module_identify.md	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,17 @@
+## 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/esp8266-driver.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/esp8266-driver/#450cc128865ffb90b5cbfe5af193621644024fa7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,538 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "simpleclient.h"
+#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
+
+#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);
+
+// These are example resource values for the Device Object
+struct MbedClientDevice device = {
+    "Manufacturer_String",      // Manufacturer
+    "Type_String",              // Type
+    "ModelNumber_String",       // ModelNumber
+    "SerialNumber_String"       // SerialNumber
+};
+
+// 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
+ * will blink based on the pattern.
+ */
+class LedResource {
+public:
+    LedResource() {
+        // create ObjectID with metadata tag of '3201', which is 'digital output'
+        led_object = M2MInterfaceFactory::create_object("3201");
+        M2MObjectInstance* led_inst = led_object->create_object_instance();
+
+        // 5855 = Multi-state output
+        M2MResource* color_res = led_inst->create_dynamic_resource("5855", "Color",
+            M2MResourceInstance::STRING, false);
+        // read and write
+        color_res->set_operation(M2MBase::GET_PUT_ALLOWED);
+        // set red as initial color
+        color_res->set_value((const uint8_t*)"red", 3);
+        
+        // 5853 = Multi-state output
+        M2MResource* pattern_res = led_inst->create_dynamic_resource("5853", "Pattern",
+            M2MResourceInstance::STRING, false);
+        // read and write
+        pattern_res->set_operation(M2MBase::GET_PUT_ALLOWED);
+        // set initial pattern (toggle every 200ms. 7 toggles in total)
+        pattern_res->set_value((const uint8_t*)"500:500:500:500:500:500:500", 27);
+
+        // there's not really an execute LWM2M ID that matches... hmm...
+        M2MResource* led_res = led_inst->create_dynamic_resource("5850", "Blink",
+            M2MResourceInstance::OPAQUE, false);
+        // we allow executing a function here...
+        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 *) {
+        // read the value of 'Pattern'
+        M2MObjectInstance* inst = led_object->object_instance();
+        M2MResource* res = inst->resource("5853");
+        // read the value of 'Color'
+        M2MObjectInstance* instC = led_object->object_instance();
+        M2MResource* resC = instC->resource("5855");
+
+        // values in mbed Client are all buffers, and we need a vector of int's
+        uint8_t* buffIn = NULL;
+        uint32_t sizeIn;
+        res->get_value(buffIn, sizeIn);
+        
+        uint8_t* cbuffIn = NULL;
+        uint32_t csizeIn;
+        resC->get_value(cbuffIn, csizeIn);
+
+        // turn the buffer into a string, and initialize a vector<int> on the heap
+        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());
+
+        // our pattern is something like 500:200:500, so parse that
+        std::size_t found = s.find_first_of(":");
+        while (found!=std::string::npos) {
+
+            v->push_back(atoi((const char*)s.substr(0,found).c_str()));
+            s = s.substr(found+1);
+            found=s.find_first_of(":");
+            if(found == std::string::npos) {
+                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);
+    }
+
+private:
+    M2MObject* led_object;
+
+    void do_blink(std::vector<uint32_t>* pattern, uint8_t* color,  uint16_t position) {
+        
+        if (!strcmp((char *)color, "red")) {
+            // blink the LED in red color
+            led1 = !led1;
+        }
+        else if (!strcmp((char *)color, "green")) {
+            // blink in green color
+            led2 = !led2;
+        }
+        else if (!strcmp((char *)color, "blue")) {
+            // blink in blue color
+            led3 = !led3;
+        }
+        else if (!strcmp((char *)color, "cyan")) {
+            // blink in cyan color
+            led2 = !led2;
+            led3 = !led3;
+        }
+        else if (!strcmp((char *)color, "yellow")) {
+            // blink in yellow color
+            led1 = !led1;
+            led2 = !led2;
+        }
+        else if (!strcmp((char *)color, "magenta")) {
+            // blink in magenta color
+            led1 = !led1;
+            led3 = !led3;
+        }            
+        else if (!strcmp((char *)color, "white")) {
+            // blink in white color
+            led1 = !led1;
+            led2 = !led2;
+            led3 = !led3;
+        }
+        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.
+ */
+class ZxingResource {
+public:
+    ZxingResource() {
+        // create ObjectID with metadata tag of '3202', which is 'send string'
+        zxing_object = M2MInterfaceFactory::create_object("3202");
+        M2MObjectInstance* zxing_inst = zxing_object->create_object_instance();
+        // create resource with ID '5700', which is 'send string'
+        M2MResource* zxing_res = zxing_inst->create_dynamic_resource("5700", "zxing",
+            M2MResourceInstance::STRING, true);
+        // we can read this value
+        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);        
+    }
+
+    ~ZxingResource() {
+    }
+
+    M2MObject* get_object() {
+        return zxing_object;
+    }
+
+    /*
+     * When you success the decode process of barcode, we send the string after decoding to mbed Device Connector.
+     */
+    void handle_string_send(char * addr, int size) {
+        M2MObjectInstance* inst = zxing_object->object_instance();
+        M2MResource* res = inst->resource("5700");
+
+        printf("%s\r\n", addr);
+
+        // tell the string to connector
+        res->set_value((uint8_t *)addr, size);
+    }
+
+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
+
+// Entry point to the program
+int main() {
+
+#ifndef MBEDTLS_ENTROPY_HARDWARE_ALT
+
+#ifdef MBEDTLS_TEST_NULL_ENTROPY
+#warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware."
+
+#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);
+
+    // Keep track of the main thread
+    mainThread = osThreadGetId();
+
+    // Sets the console baud-rate
+    output.baud(115200);
+
+    output.printf("Starting mbed Client example...\r\n");
+
+    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
+    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;
+    }
+    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);
+
+    // 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
+    M2MDevice*   device_object   = mbed_client.create_device_object();   // device resources object
+
+    // Create list of Objects to register
+    M2MObjectList object_list;
+
+    // Add objects to list
+    object_list.push_back(device_object);
+#if(1)  //for zxing with camera
+    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();
+
+    while (registered) {
+        if (zxing_loop() == 0) {
+            update_timer.reset();
+        } else if (update_timer.read() >= 25) {
+            mbed_client.test_update_register();
+            update_timer.reset();
+        } else {
+            // do nothing
+        }
+        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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,1 @@
+https://github.com/Osamu-Nakamura/mbed-os/#2aa12b8e5572ed7e6676351952e91281260252eb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,47 @@
+{
+    "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"]
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_client_config.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MBED_CLIENT_CONFIG_H
+#define MBED_CLIENT_CONFIG_H
+
+
+// Defines the number of times client should try re-connection towards
+// Server in case of connectivity loss , also defines the number of CoAP
+// re-transmission attempts.Default value is 3
+#define M2M_CLIENT_RECONNECTION_COUNT		3
+
+// Defines the interval (in seconds) in which client should try re-connection towards
+// Server in case of connectivity loss , also use the same interval for CoAP
+// re-transmission attempts. Default value is 5 seconds
+#define M2M_CLIENT_RECONNECTION_INTERVAL	5
+
+// Defines the keep-alive interval (in seconds) in which client should send keep alive
+// pings to server while connected through TCP mode. Default value is 300 seconds
+#define M2M_CLIENT_TCP_KEEPALIVE_TIME 		300
+
+// Defines the maximum CoAP messages that client can hold, maximum value is 6
+#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT  2
+
+// Defines the size of blockwise CoAP messages that client can handle.
+// The values that can be defined uust be 2^x and x is at least 4.
+// Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024
+#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE  1024
+
+// Many pure LWM2M servers doen't accept 'obs' text in registration message.
+// While using Client against such servers, this flag can be set to define to
+// disable client sending 'obs' text for observable resources.
+#undef COAP_DISABLE_OBS_FEATURE
+
+// Disable Bootstrap functionality in client in order to reduce code size, if bootstrap
+// functionality is not required.
+#undef M2M_CLIENT_DISABLE_BOOTSTRAP_FEATURE
+
+#endif // MBED_CLIENT_CONFIG_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedtls_mbed_client_config.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,115 @@
+/*
+ *  Minimal configuration for using mbedtls as part of mbed-client
+ *
+ *  Copyright (C) 2006-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.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  This file is part of mbed TLS (https://tls.mbed.org)
+ */
+
+
+#ifndef MBEDTLS_CUSTOM_CONFIG_H
+#define MBEDTLS_CUSTOM_CONFIG_H
+
+/* System support */
+#define MBEDTLS_HAVE_ASM
+
+/* mbed TLS feature support */
+#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
+#define MBEDTLS_ECP_NIST_OPTIM
+#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+#define MBEDTLS_SSL_PROTO_TLS1_2
+#define MBEDTLS_SSL_PROTO_DTLS
+#define MBEDTLS_SSL_DTLS_ANTI_REPLAY
+#define MBEDTLS_SSL_DTLS_HELLO_VERIFY
+#define MBEDTLS_SSL_EXPORT_KEYS
+
+/* mbed TLS modules */
+#define MBEDTLS_AES_C
+#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
+#define MBEDTLS_ENTROPY_C
+#define MBEDTLS_MD_C
+#define MBEDTLS_OID_C
+#define MBEDTLS_PK_C
+#define MBEDTLS_PK_PARSE_C
+#define MBEDTLS_SHA256_C
+#define MBEDTLS_SSL_COOKIE_C
+#define MBEDTLS_SSL_CLI_C
+#define MBEDTLS_SSL_SRV_C
+#define MBEDTLS_SSL_TLS_C
+
+// 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
+
+// Remove RSA, save 20KB at total
+#undef MBEDTLS_RSA_C
+#undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
+
+// Remove error messages, save 10KB of ROM
+#undef MBEDTLS_ERROR_C
+
+// 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
+#undef MBEDTLS_DEBUG_C
+
+// needed for parsing the certificates
+#define MBEDTLS_PEM_PARSE_C
+// dep of the previous
+#define MBEDTLS_BASE64_C
+
+// 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
+#undef MBEDTLS_AES_ROM_TABLES
+
+// Save ROM and a few bytes of RAM by specifying our own ciphersuite list
+#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
+
+#include "mbedtls/check_config.h"
+
+#endif /* MBEDTLS_CUSTOM_CONFIG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/security.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __SECURITY_H__
+#define __SECURITY_H__
+ 
+#include <inttypes.h>
+ 
+#define MBED_DOMAIN "DOMAIN"
+#define MBED_ENDPOINT_NAME "ENDPOINT_NAME"
+ 
+const uint8_t SERVER_CERT[] = "-----BEGIN CERTIFICATE-----\r\n"
+"-----END CERTIFICATE-----\r\n";
+ 
+const uint8_t CERT[] = "-----BEGIN CERTIFICATE-----\r\n"
+"-----END CERTIFICATE-----\r\n";
+ 
+const uint8_t KEY[] = "-----BEGIN PRIVATE KEY-----\r\n"
+"-----END PRIVATE KEY-----\r\n";
+ 
+#endif //__SECURITY_H__
+ 
+#error "You need to get security.h credentials from connector.mbed.com and replace the content of this security.h file"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpleclient.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SIMPLECLIENT_H__
+#define __SIMPLECLIENT_H__
+
+#include "mbed-client/m2minterfacefactory.h"
+#include "mbed-client/m2mdevice.h"
+#include "mbed-client/m2minterfaceobserver.h"
+#include "mbed-client/m2minterface.h"
+#include "mbed-client/m2mobject.h"
+#include "mbed-client/m2mobjectinstance.h"
+#include "mbed-client/m2mresource.h"
+#include "mbed-client/m2mconfig.h"
+#include "security.h"
+#include "mbed.h"
+
+//Select binding mode: UDP or TCP
+M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP;
+
+// MBED_DOMAIN and MBED_ENDPOINT_NAME come
+// from the security.h file copied from connector.mbed.com
+
+struct MbedClientDevice {
+    const char* Manufacturer;
+    const char* Type;
+    const char* ModelNumber;
+    const char* SerialNumber;
+};
+
+/*
+* Wrapper for mbed client stack that handles all callbacks, error handling, and
+* other shenanigans to make the mbed client stack easier to use.
+*
+* The end user should only have to care about configuring the parameters at the
+* top of this file and making sure they add the security.h file correctly.
+* To add resources you can copy the _TODO__ function and add as many instances as
+* you want.
+*
+*/
+class MbedClient: public M2MInterfaceObserver {
+public:
+
+    // constructor for MbedClient object, initialize private variables
+    MbedClient(struct MbedClientDevice device) {
+        _interface = NULL;
+        _bootstrapped = false;
+        _error = false;
+        _registered = false;
+        _unregistered = false;
+        _register_security = NULL;
+        _value = 0;
+        _object = NULL;
+        _device = device;
+    }
+
+    // de-constructor for MbedClient object, you can ignore this
+    ~MbedClient() {
+        if(_interface) {
+            delete _interface;
+        }
+        if(_register_security){
+            delete _register_security;
+        }
+    }
+
+    // debug printf function
+    void trace_printer(const char* str) {
+        printf("\r\n%s\r\n", str);
+    }
+
+    /*
+    *  Creates M2MInterface using which endpoint can
+    *  setup its name, resource type, life time, connection mode,
+    *  Currently only LwIPv4 is supported.
+    */
+    void create_interface(const char *server_address,
+                          void *handler=NULL) {
+	// Randomizing listening port for Certificate mode connectivity
+    _server_address = server_address;
+	srand(time(NULL));
+	uint16_t port = rand() % 65535 + 12345;
+
+    // create mDS interface object, this is the base object everything else attaches to
+    _interface = M2MInterfaceFactory::create_interface(*this,
+                                                      MBED_ENDPOINT_NAME,       // endpoint name string
+                                                      "test",                   // endpoint type string
+                                                      100,                      // lifetime
+                                                      port,                     // listen port
+                                                      MBED_DOMAIN,              // domain string
+                                                      SOCKET_MODE,              // binding mode
+                                                      M2MInterface::LwIP_IPv4,  // network stack
+                                                      "");                      // context address string
+    const char *binding_mode = (SOCKET_MODE == M2MInterface::UDP) ? "UDP" : "TCP";
+    printf("\r\nSOCKET_MODE : %s\r\n", binding_mode);
+    printf("Connecting to %s\r\n", server_address);
+
+    if(_interface) {
+        _interface->set_platform_network_handler(handler);
+    }
+
+    }
+
+    /*
+    *  check private variable to see if the registration was sucessful or not
+    */
+    bool register_successful() {
+        return _registered;
+    }
+
+    /*
+    *  check private variable to see if un-registration was sucessful or not
+    */
+    bool unregister_successful() {
+        return _unregistered;
+    }
+
+    /*
+    *  Creates register server object with mbed device server address and other parameters
+    *  required for client to connect to mbed device server.
+    */
+    M2MSecurity* create_register_object() {
+        // create security object using the interface factory.
+        // this will generate a security ObjectID and ObjectInstance
+        M2MSecurity *security = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer);
+
+        // make sure security ObjectID/ObjectInstance was created successfully
+        if(security) {
+            // 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));
+        }
+        return security;
+    }
+
+    /*
+    * Creates device object which contains mandatory resources linked with
+    * device endpoint.
+    */
+    M2MDevice* create_device_object() {
+        // create device objectID/ObjectInstance
+        M2MDevice *device = M2MInterfaceFactory::create_device();
+        // make sure device object was created successfully
+        if(device) {
+            // add resourceID's to device objectID/ObjectInstance
+            device->create_resource(M2MDevice::Manufacturer, _device.Manufacturer);
+            device->create_resource(M2MDevice::DeviceType, _device.Type);
+            device->create_resource(M2MDevice::ModelNumber, _device.ModelNumber);
+            device->create_resource(M2MDevice::SerialNumber, _device.SerialNumber);
+        }
+        return device;
+    }
+
+    /*
+    * register an object
+    */
+    void test_register(M2MSecurity *register_object, M2MObjectList object_list){
+        if(_interface) {
+            // Register function
+            _interface->register_object(register_object, object_list);
+        }
+    }
+
+    /*
+    * unregister all objects
+    */
+    void test_unregister() {
+        if(_interface) {
+            // Unregister function
+            _interface->unregister_object(NULL); // NULL will unregister all objects
+        }
+    }
+
+    //Callback from mbed client stack when the bootstrap
+    // is successful, it returns the mbed Device Server object
+    // which will be used for registering the resources to
+    // mbed Device server.
+    void bootstrap_done(M2MSecurity *server_object){
+        if(server_object) {
+            _bootstrapped = true;
+            _error = false;
+            trace_printer("Bootstrapped");
+        }
+    }
+
+    //Callback from mbed client stack when the registration
+    // is successful, it returns the mbed Device Server object
+    // to which the resources are registered and registered objects.
+    void object_registered(M2MSecurity */*security_object*/, const M2MServer &/*server_object*/){
+        _registered = true;
+        _unregistered = false;
+        trace_printer("Registered object successfully!");
+    }
+
+    //Callback from mbed client stack when the unregistration
+    // is successful, it returns the mbed Device Server object
+    // to which the resources were unregistered.
+    void object_unregistered(M2MSecurity */*server_object*/){
+        trace_printer("Unregistered Object Successfully");
+        _unregistered = true;
+        _registered = false;               
+    }
+
+    /*
+    * Callback from mbed client stack when registration is updated
+    */
+    void registration_updated(M2MSecurity */*security_object*/, const M2MServer & /*server_object*/){
+        /* The registration is updated automatically and frequently by the
+        *  mbed client stack. This print statement is turned off because it
+        *  tends to happen alot.
+        */
+        //trace_printer("\r\nRegistration Updated\r\n");
+    }
+
+    // Callback from mbed client stack if any error is encountered
+    // during any of the LWM2M operations. Error type is passed in
+    // the callback.
+    void error(M2MInterface::Error error){
+        _error = true;
+        switch(error){
+            case M2MInterface::AlreadyExists:
+                trace_printer("[ERROR:] M2MInterface::AlreadyExist");
+                break;
+            case M2MInterface::BootstrapFailed:
+                trace_printer("[ERROR:] M2MInterface::BootstrapFailed");
+                break;
+            case M2MInterface::InvalidParameters:
+                trace_printer("[ERROR:] M2MInterface::InvalidParameters");
+                break;
+            case M2MInterface::NotRegistered:
+                trace_printer("[ERROR:] M2MInterface::NotRegistered");
+                break;
+            case M2MInterface::Timeout:
+                trace_printer("[ERROR:] M2MInterface::Timeout");
+                break;
+            case M2MInterface::NetworkError:
+                trace_printer("[ERROR:] M2MInterface::NetworkError");
+                break;
+            case M2MInterface::ResponseParseFailed:
+                trace_printer("[ERROR:] M2MInterface::ResponseParseFailed");
+                break;
+            case M2MInterface::UnknownError:
+                trace_printer("[ERROR:] M2MInterface::UnknownError");
+                break;
+            case M2MInterface::MemoryFail:
+                trace_printer("[ERROR:] M2MInterface::MemoryFail");
+                break;
+            case M2MInterface::NotAllowed:
+                trace_printer("[ERROR:] M2MInterface::NotAllowed");
+                break;
+            case M2MInterface::SecureConnectionFailed:
+                trace_printer("[ERROR:] M2MInterface::SecureConnectionFailed");
+                break;
+            case M2MInterface::DnsResolvingFailed:
+                trace_printer("[ERROR:] M2MInterface::DnsResolvingFailed");
+                break;
+
+            default:
+                break;
+        }
+    }
+
+    /* Callback from mbed client stack if any value has changed
+    *  during PUT operation. Object and its type is passed in
+    *  the callback.
+    *  BaseType enum from m2mbase.h
+    *       Object = 0x0, Resource = 0x1, ObjectInstance = 0x2, ResourceInstance = 0x3
+    */
+    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(),
+               type,
+               base->resource_type().c_str()
+               );
+    }
+
+    /*
+    * update the registration period
+    */
+    void test_update_register() {
+        if (_registered) {
+            _interface->update_registration(_register_security, 100);
+        }
+    }
+
+    /*
+    * manually configure the security object private variable
+    */
+   void set_register_object(M2MSecurity *register_object) {
+        if (_register_security == NULL) {
+            _register_security = register_object;
+        }
+    }
+
+private:
+
+    /*
+    *  Private variables used in class
+    */
+    M2MInterface    	     *_interface;
+    M2MSecurity              *_register_security;
+    M2MObject                *_object;
+    volatile bool            _bootstrapped;
+    volatile bool            _error;
+    volatile bool            _registered;
+    volatile bool            _unregistered;
+    int                      _value;
+    struct MbedClientDevice  _device;
+    String                   _server_address;
+};
+
+#endif // __SIMPLECLIENT_H__
Binary file zxing.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/ImageReaderSource.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,77 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __IMAGE_READER_SOURCE_H_
+#define __IMAGE_READER_SOURCE_H_
+/*
+ *  Copyright 2010-2011 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mbed.h"
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <zxing/LuminanceSource.h>
+#include <zxing/common/Counted.h>
+#include <zxing/Binarizer.h>
+#include <zxing/MultiFormatReader.h>
+#include <zxing/Result.h>
+#include <zxing/ReaderException.h>
+#include <zxing/common/GlobalHistogramBinarizer.h>
+#include <zxing/common/HybridBinarizer.h>
+#include <exception>
+#include <zxing/Exception.h>
+#include <zxing/common/IllegalArgumentException.h>
+#include <zxing/BinaryBitmap.h>
+#include <zxing/DecodeHints.h>
+
+#include <zxing/qrcode/QRCodeReader.h>
+#include <zxing/multi/qrcode/QRCodeMultiReader.h>
+#include <zxing/multi/ByQuadrantReader.h>
+#include <zxing/multi/MultipleBarcodeReader.h>
+#include <zxing/multi/GenericMultipleBarcodeReader.h>
+
+using std::string;
+using std::ostringstream;
+using zxing::Ref;
+using zxing::ArrayRef;
+using zxing::LuminanceSource;
+
+using namespace std;
+using namespace zxing;
+using namespace zxing::multi;
+using namespace zxing::qrcode;
+
+
+class ImageReaderSource : public zxing::LuminanceSource {
+private:
+  typedef LuminanceSource Super;
+
+  const zxing::ArrayRef<char> image;
+  const int comps;
+
+  char convertPixel(const char* pixel) const;
+
+public:
+  static zxing::Ref<LuminanceSource> create(char* buf, int buf_size, int width, int height);
+
+  ImageReaderSource(zxing::ArrayRef<char> image, int width, int height, int comps);
+
+  zxing::ArrayRef<char> getRow(int y, zxing::ArrayRef<char> row) const;
+  zxing::ArrayRef<char> getMatrix() const;
+};
+
+extern int ex_decode(uint8_t* buf, int buf_size, int width, int height, vector<Ref<Result> > * results);
+
+
+#endif /* __IMAGE_READER_SOURCE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/BarcodeFormat.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,60 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __BARCODE_FORMAT_H__
+#define __BARCODE_FORMAT_H__
+
+/*
+ *  BarcodeFormat.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace zxing {
+
+class BarcodeFormat {
+public:
+  // if you update the enum, update BarcodeFormat.cpp
+
+  enum Value {
+    NONE,
+    AZTEC,
+    CODABAR,
+    CODE_39,
+    CODE_93,
+    CODE_128,
+    DATA_MATRIX,
+    EAN_8,
+    EAN_13,
+    ITF,
+    MAXICODE,
+    PDF_417,
+    QR_CODE,
+    RSS_14,
+    RSS_EXPANDED,
+    UPC_A,
+    UPC_E,
+    UPC_EAN_EXTENSION
+  };
+
+  BarcodeFormat(Value v) : value(v) {}  
+  const Value value;
+  operator Value () const {return value;}
+
+  static char const* barcodeFormatNames[];
+};
+
+}
+
+#endif // __BARCODE_FORMAT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/Binarizer.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,50 @@
+#ifndef BINARIZER_H_
+#define BINARIZER_H_
+
+/*
+ *  Binarizer.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/LuminanceSource.h>
+#include <zxing/common/BitArray.h>
+#include <zxing/common/BitMatrix.h>
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+class Binarizer : public Counted {
+ private:
+  Ref<LuminanceSource> source_;
+
+ public:
+  Binarizer(Ref<LuminanceSource> source);
+  virtual ~Binarizer();
+
+  virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row) = 0;
+  virtual Ref<BitMatrix> getBlackMatrix() = 0;
+
+  Ref<LuminanceSource> getLuminanceSource() const ;
+  virtual Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source) = 0;
+
+  int getWidth() const;
+  int getHeight() const;
+
+};
+
+}
+#endif /* BINARIZER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/BinaryBitmap.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,56 @@
+#ifndef __BINARYBITMAP_H__
+#define __BINARYBITMAP_H__
+
+/*
+ *  BinaryBitmap.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+#include <zxing/common/BitMatrix.h>
+#include <zxing/common/BitArray.h>
+#include <zxing/Binarizer.h>
+
+namespace zxing {
+	
+	class BinaryBitmap : public Counted {
+	private:
+		Ref<Binarizer> binarizer_;
+		
+	public:
+		BinaryBitmap(Ref<Binarizer> binarizer);
+		virtual ~BinaryBitmap();
+		
+		Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
+		Ref<BitMatrix> getBlackMatrix();
+		
+		Ref<LuminanceSource> getLuminanceSource() const;
+
+		int getWidth() const;
+		int getHeight() const;
+
+		bool isRotateSupported() const;
+		Ref<BinaryBitmap> rotateCounterClockwise();
+
+		bool isCropSupported() const;
+		Ref<BinaryBitmap> crop(int left, int top, int width, int height);
+
+	};
+	
+}
+
+#endif /* BINARYBITMAP_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/DecodeHints.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,89 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __DECODEHINTS_H_
+#define __DECODEHINTS_H_
+/*
+ *  DecodeHintType.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/BarcodeFormat.h>
+#include <zxing/ResultPointCallback.h>
+
+namespace zxing {
+
+typedef unsigned int DecodeHintType;
+class DecodeHints;
+DecodeHints operator | (DecodeHints const&, DecodeHints const&);
+
+class DecodeHints {
+ private:
+  DecodeHintType hints;
+  Ref<ResultPointCallback> callback;
+
+ public:
+  static const DecodeHintType AZTEC_HINT = 1 << BarcodeFormat::AZTEC;
+  static const DecodeHintType CODABAR_HINT = 1 << BarcodeFormat::CODABAR;
+  static const DecodeHintType CODE_39_HINT = 1 << BarcodeFormat::CODE_39;
+  static const DecodeHintType CODE_93_HINT = 1 << BarcodeFormat::CODE_93;
+  static const DecodeHintType CODE_128_HINT = 1 << BarcodeFormat::CODE_128;
+  static const DecodeHintType DATA_MATRIX_HINT = 1 << BarcodeFormat::DATA_MATRIX;
+  static const DecodeHintType EAN_8_HINT = 1 << BarcodeFormat::EAN_8;
+  static const DecodeHintType EAN_13_HINT = 1 << BarcodeFormat::EAN_13;
+  static const DecodeHintType ITF_HINT = 1 << BarcodeFormat::ITF;
+  static const DecodeHintType MAXICODE_HINT = 1 << BarcodeFormat::MAXICODE;
+  static const DecodeHintType PDF_417_HINT = 1 << BarcodeFormat::PDF_417;
+  static const DecodeHintType QR_CODE_HINT = 1 << BarcodeFormat::QR_CODE;
+  static const DecodeHintType RSS_14_HINT = 1 << BarcodeFormat::RSS_14;
+  static const DecodeHintType RSS_EXPANDED_HINT = 1 << BarcodeFormat::RSS_EXPANDED;
+  static const DecodeHintType UPC_A_HINT = 1 << BarcodeFormat::UPC_A;
+  static const DecodeHintType UPC_E_HINT = 1 << BarcodeFormat::UPC_E;
+  static const DecodeHintType UPC_EAN_EXTENSION_HINT = 1 << BarcodeFormat::UPC_EAN_EXTENSION;
+
+#if defined(__ICCARM__)             //
+  static const DecodeHintType TRYHARDER_HINT = 0x80000000;
+#else
+  static const DecodeHintType TRYHARDER_HINT = 1 << 31;
+#endif                              //
+  static const DecodeHintType CHARACTER_SET = 1 << 30;
+  // static const DecodeHintType ALLOWED_LENGTHS = 1 << 29;
+  // static const DecodeHintType ASSUME_CODE_39_CHECK_DIGIT = 1 << 28;
+  static const DecodeHintType  ASSUME_GS1 = 1 << 27;
+  // static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26;
+  
+  static const DecodeHints PRODUCT_HINT;
+  static const DecodeHints ONED_HINT;
+  static const DecodeHints DEFAULT_HINT;
+
+  DecodeHints();
+  DecodeHints(DecodeHintType init);
+
+  void addFormat(BarcodeFormat toadd);
+  bool containsFormat(BarcodeFormat tocheck) const;
+  bool isEmpty() const {return (hints==0);}
+  void clear() {hints=0;}
+  void setTryHarder(bool toset);
+  bool getTryHarder() const;
+
+  void setResultPointCallback(Ref<ResultPointCallback> const&);
+  Ref<ResultPointCallback> getResultPointCallback() const;
+
+  friend DecodeHints operator | (DecodeHints const&, DecodeHints const&);
+};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/Exception.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,51 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __EXCEPTION_H__
+#define __EXCEPTION_H__
+
+/*
+ *  Exception.h
+ *  ZXing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+#include <exception>
+
+namespace zxing {
+
+class Exception : public std::exception {
+private:
+  char const* const message;
+
+public:
+  Exception() throw() : message(0) {}
+  Exception(const char* msg) throw() : message(copy(msg)) {}
+  Exception(Exception const& that) throw() : std::exception(that), message(copy(that.message)) {}
+  ~Exception() throw() {
+    if(message) {
+      deleteMessage();
+    }
+  }
+  char const* what() const throw() {return message ? message : "";}
+
+private:
+  static char const* copy(char const*);
+  void deleteMessage();
+};
+
+}
+
+#endif // __EXCEPTION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/LuminanceSource.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,59 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __LUMINANCESOURCE_H__
+#define __LUMINANCESOURCE_H__
+/*
+ *  LuminanceSource.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+#include <zxing/common/Array.h>
+#include <string.h>
+
+namespace zxing {
+
+class LuminanceSource : public Counted {
+ private:
+  const int width;
+  const int height;
+
+ public:
+  LuminanceSource(int width, int height);
+  virtual ~LuminanceSource();
+
+  int getWidth() const { return width; }
+  int getHeight() const { return height; }
+
+  // Callers take ownership of the returned memory and must call delete [] on it themselves.
+  virtual ArrayRef<char> getRow(int y, ArrayRef<char> row) const = 0;
+  virtual ArrayRef<char> getMatrix() const = 0;
+
+  virtual bool isCropSupported() const;
+  virtual Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
+
+  virtual bool isRotateSupported() const;
+
+  virtual Ref<LuminanceSource> invert() const;
+  
+  virtual Ref<LuminanceSource> rotateCounterClockwise() const;
+
+  operator std::string () const;
+};
+
+}
+
+#endif /* LUMINANCESOURCE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/MultiFormatReader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,48 @@
+#ifndef __MULTI_FORMAT_READER_H__
+#define __MULTI_FORMAT_READER_H__
+
+/*
+ *  MultiFormatBarcodeReader.h
+ *  ZXing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ 
+#include <zxing/Reader.h>
+#include <zxing/common/BitArray.h>
+#include <zxing/Result.h>
+#include <zxing/DecodeHints.h>
+
+namespace zxing {
+  class MultiFormatReader : public Reader {
+  private:
+    Ref<Result> decodeInternal(Ref<BinaryBitmap> image);
+  
+    std::vector<Ref<Reader> > readers_;
+    DecodeHints hints_;
+
+  public:
+    MultiFormatReader();
+    
+    Ref<Result> decode(Ref<BinaryBitmap> image);
+    Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
+    Ref<Result> decodeWithState(Ref<BinaryBitmap> image);
+    void setHints(DecodeHints hints);
+    ~MultiFormatReader();
+  };
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/Reader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,40 @@
+#ifndef __READER_H__
+#define __READER_H__
+
+/*
+ *  Reader.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/BinaryBitmap.h>
+#include <zxing/Result.h>
+#include <zxing/DecodeHints.h>
+
+namespace zxing {
+
+ class Reader : public Counted {
+  protected:
+   Reader() {}
+  public:
+   virtual Ref<Result> decode(Ref<BinaryBitmap> image);
+   virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
+   virtual ~Reader();
+};
+
+}
+
+#endif // __READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/ReaderException.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,37 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __READER_EXCEPTION_H__
+#define __READER_EXCEPTION_H__
+
+/*
+ *  ReaderException.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/Exception.h>
+
+namespace zxing {
+
+class ReaderException : public Exception {
+ public:
+  ReaderException() throw() {}
+  ReaderException(char const* msg) throw() : Exception(msg) {}
+  ~ReaderException() throw() {}
+};
+
+}
+
+#endif // __READER_EXCEPTION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/Result.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,55 @@
+#ifndef __RESULT_H__
+#define __RESULT_H__
+
+/*
+ *  Result.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+#include <zxing/common/Array.h>
+#include <zxing/common/Counted.h>
+#include <zxing/common/Str.h>
+#include <zxing/ResultPoint.h>
+#include <zxing/BarcodeFormat.h>
+
+namespace zxing {
+
+class Result : public Counted {
+private:
+  Ref<String> text_;
+  ArrayRef<char> rawBytes_;
+  ArrayRef< Ref<ResultPoint> > resultPoints_;
+  BarcodeFormat format_;
+
+public:
+  Result(Ref<String> text,
+         ArrayRef<char> rawBytes,
+         ArrayRef< Ref<ResultPoint> > resultPoints,
+         BarcodeFormat format);
+  ~Result();
+  Ref<String> getText();
+  ArrayRef<char> getRawBytes();
+  ArrayRef< Ref<ResultPoint> > const& getResultPoints() const;
+  ArrayRef< Ref<ResultPoint> >& getResultPoints();
+  BarcodeFormat getBarcodeFormat() const;
+
+  friend std::ostream& operator<<(std::ostream &out, Result& result);
+};
+
+}
+#endif // __RESULT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/ResultPoint.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,55 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __RESULT_POINT_H__
+#define __RESULT_POINT_H__
+
+/*
+ *  ResultPoint.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+#include <vector>
+
+namespace zxing {
+
+class ResultPoint : public Counted {
+protected:
+  const float posX_;
+  const float posY_;
+  
+public:
+  ResultPoint();
+  ResultPoint(float x, float y);
+  ResultPoint(int x, int y);
+  virtual ~ResultPoint();
+
+  virtual float getX() const;
+  virtual float getY() const;
+
+  bool equals(Ref<ResultPoint> other);
+
+  static void orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns);
+  static float distance(Ref<ResultPoint> point1, Ref<ResultPoint> point2);
+  static float distance(float x1, float x2, float y1, float y2);
+
+private:
+  static float crossProductZ(Ref<ResultPoint> pointA, Ref<ResultPoint> pointB, Ref<ResultPoint> pointC);
+};
+
+}
+
+#endif // __RESULT_POINT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/ResultPointCallback.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,39 @@
+#ifndef __RESULT_POINT_CALLBACK_H__
+#define __RESULT_POINT_CALLBACK_H__
+
+/*
+ *  ResultPointCallback.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+class ResultPoint;
+
+class ResultPointCallback : public Counted {
+protected:
+  ResultPointCallback() {}
+public:
+  virtual void foundPossibleResultPoint(ResultPoint const& point) = 0;
+  virtual ~ResultPointCallback();
+};
+
+}
+
+#endif // __RESULT_POINT_CALLBACK_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/ZXing.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,135 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+/*
+ *  Copyright 2013 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __ZXING_H_
+#define __ZXING_H_
+
+#define ZXING_ARRAY_LEN(v) ((int)(sizeof(v)/sizeof(v[0])))
+#define ZX_LOG_DIGITS(digits) \
+    ((digits == 8) ? 3 : \
+     ((digits == 16) ? 4 : \
+      ((digits == 32) ? 5 : \
+       ((digits == 64) ? 6 : \
+        ((digits == 128) ? 7 : \
+         (-1))))))
+
+#ifndef ZXING_DEBUG
+#define ZXING_DEBUG 0
+#endif
+
+namespace zxing {
+typedef char byte;
+typedef bool boolean;
+}
+
+#include <limits>
+
+#if defined(_WIN32) || defined(_WIN64)
+
+#include <float.h>
+
+namespace zxing {
+inline bool isnan(float v) {return _isnan(v) != 0;}
+inline bool isnan(double v) {return _isnan(v) != 0;}
+inline float nan() {return std::numeric_limits<float>::quiet_NaN();}
+}
+
+#else
+
+#include <cmath>
+
+namespace zxing {
+#if defined(__ICCARM__) || defined( __CC_ARM )  //
+#else                                           //
+inline bool isnan(float v) {return std::isnan(v);}
+inline bool isnan(double v) {return std::isnan(v);}
+#endif                                          //
+inline float nan() {return std::numeric_limits<float>::quiet_NaN();}
+}
+#endif
+
+#if ZXING_DEBUG
+
+#include <iostream>
+#include <string>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::flush;
+using std::string;
+using std::ostream;
+
+#if ZXING_DEBUG_TIMER
+
+#include <sys/time.h>
+
+namespace zxing {
+
+class DebugTimer {
+public:
+  DebugTimer(char const* string_) : chars(string_) {
+    gettimeofday(&start, 0);
+  }
+
+  DebugTimer(std::string const& string_) : chars(0), string(string_) {
+    gettimeofday(&start, 0);
+  }
+
+  void mark(char const* string) {
+    struct timeval end;
+    gettimeofday(&end, 0);
+    int diff =
+      (end.tv_sec - start.tv_sec)*1000*1000+(end.tv_usec - start.tv_usec);
+    
+    cerr << diff << " " << string << '\n';
+  }
+
+  void mark(std::string string) {
+    mark(string.c_str());
+  }
+
+  ~DebugTimer() {
+    if (chars) {
+      mark(chars);
+    } else {
+      mark(string.c_str());
+    }
+  }
+
+private:
+  char const* const chars;
+  std::string string;
+  struct timeval start;
+};
+
+}
+
+#define ZXING_TIME(string) DebugTimer __timer__ (string)
+#define ZXING_TIME_MARK(string) __timer__.mark(string)
+
+#endif
+
+#endif // ZXING_DEBUG
+
+#ifndef ZXING_TIME
+#define ZXING_TIME(string) (void)0
+#endif
+#ifndef ZXING_TIME_MARK
+#define ZXING_TIME_MARK(string) (void)0
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/Array.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,170 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __ARRAY_H__
+#define __ARRAY_H__
+
+/*
+ *  Array.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vector>
+
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+template<typename T> class Array : public Counted {
+protected:
+public:
+  std::vector<T> values_;
+  Array() {}
+  Array(int n) :
+      Counted(), values_(n, T()) {
+  }
+  Array(T const* ts, int n) :
+      Counted(), values_(ts, ts+n) {
+  }
+  Array(T const* ts, T const* te) :
+      Counted(), values_(ts, te) {
+  }
+  Array(T v, int n) :
+      Counted(), values_(n, v) {
+  }
+  Array(std::vector<T> &v) :
+      Counted(), values_(v) {
+  }
+  Array(Array<T> &other) :
+      Counted(), values_(other.values_) {
+  }
+  Array(Array<T> *other) :
+      Counted(), values_(other->values_) {
+  }
+  virtual ~Array() {
+  }
+  Array<T>& operator=(const Array<T> &other) {
+    values_ = other.values_;
+    return *this;
+  }
+  Array<T>& operator=(const std::vector<T> &array) {
+    values_ = array;
+    return *this;
+  }
+  T const& operator[](int i) const {
+    return values_[i];
+  }
+  T& operator[](int i) {
+    return values_[i];
+  }
+  int size() const {
+    return values_.size();
+  }
+  bool empty() const {
+    return values_.size() == 0;
+  }
+  std::vector<T> const& values() const {
+    return values_;
+  }
+  std::vector<T>& values() {
+    return values_;
+  }
+};
+
+template<typename T> class ArrayRef : public Counted {
+private:
+public:
+  Array<T> *array_;
+  ArrayRef() :
+      array_(0) {
+  }
+  explicit ArrayRef(int n) :
+      array_(0) {
+    reset(new Array<T> (n));
+  }
+  ArrayRef(T *ts, int n) :
+      array_(0) {
+    reset(new Array<T> (ts, n));
+  }
+  ArrayRef(Array<T> *a) :
+      array_(0) {
+    reset(a);
+  }
+  ArrayRef(const ArrayRef &other) :
+      Counted(), array_(0) {
+    reset(other.array_);
+  }
+
+  template<class Y>
+  ArrayRef(const ArrayRef<Y> &other) :
+      array_(0) {
+    reset(static_cast<const Array<T> *>(other.array_));
+  }
+
+  ~ArrayRef() {
+    if (array_) {
+      array_->release();
+    }
+    array_ = 0;
+  }
+
+  T const& operator[](int i) const {
+    return (*array_)[i];
+  }
+
+  T& operator[](int i) {
+    return (*array_)[i];
+  }
+
+  void reset(Array<T> *a) {
+    if (a) {
+      a->retain();
+    }
+    if (array_) {
+      array_->release();
+    }
+    array_ = a;
+  }
+  void reset(const ArrayRef<T> &other) {
+    reset(other.array_);
+  }
+  ArrayRef<T>& operator=(const ArrayRef<T> &other) {
+    reset(other);
+    return *this;
+  }
+  ArrayRef<T>& operator=(Array<T> *a) {
+    reset(a);
+    return *this;
+  }
+
+  Array<T>& operator*() const {
+    return *array_;
+  }
+
+  Array<T>* operator->() const {
+    return array_;
+  }
+
+  operator bool () const {
+    return array_ != 0;
+  }
+  bool operator ! () const {
+    return array_ == 0;
+  }
+};
+
+} // namespace zxing
+
+#endif // __ARRAY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/BitArray.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,81 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __BIT_ARRAY_H__
+#define __BIT_ARRAY_H__
+
+/*
+ *  Copyright 2010 ZXing authors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/ZXing.h>
+#include <zxing/common/Counted.h>
+#include <zxing/common/IllegalArgumentException.h>
+#include <zxing/common/Array.h>
+#include <vector>
+#include <limits>
+#include <iostream>
+
+namespace zxing {
+
+class BitArray : public Counted {
+public:
+  static const int bitsPerWord = std::numeric_limits<unsigned int>::digits;
+
+private:
+  int size;
+  ArrayRef<int> bits;
+  static const int logBits = ZX_LOG_DIGITS(bitsPerWord);
+  static const int bitsMask = (1 << logBits) - 1;
+
+public:
+  BitArray(int size);
+  ~BitArray();
+  int getSize() const;
+
+  bool get(int i) const {
+    return (bits[i >> logBits] & (1 << (i & bitsMask))) != 0;
+  }
+
+  void set(int i) {
+    bits[i >> logBits] |= 1 << (i & bitsMask);
+  }
+
+  int getNextSet(int from);
+  int getNextUnset(int from);
+
+  void setBulk(int i, int newBits);
+  void setRange(int start, int end);
+  void clear();
+  bool isRange(int start, int end, bool value);
+  std::vector<int>& getBitArray();
+  
+  void reverse();
+
+  class Reverse {
+   private:
+    Ref<BitArray> array;
+   public:
+    Reverse(Ref<BitArray> array);
+    ~Reverse();
+  };
+
+private:
+  static int makeArraySize(int size);
+};
+
+std::ostream& operator << (std::ostream&, BitArray const&);
+
+}
+
+#endif // __BIT_ARRAY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/BitMatrix.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,94 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __BIT_MATRIX_H__
+#define __BIT_MATRIX_H__
+
+/*
+ *  BitMatrix.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+#include <zxing/common/BitArray.h>
+#include <zxing/common/Array.h>
+#include <limits>
+#if defined(__ICCARM__)             //
+#include <stddef.h> /*for size_t*/  //
+#endif                              //
+
+namespace zxing {
+
+class BitMatrix : public Counted {
+public:
+  static const int bitsPerWord = std::numeric_limits<unsigned int>::digits;
+
+private:
+  int width;
+  int height;
+  int rowSize;
+  ArrayRef<int> bits;
+
+#define ZX_LOG_DIGITS(digits) \
+    ((digits == 8) ? 3 : \
+     ((digits == 16) ? 4 : \
+      ((digits == 32) ? 5 : \
+       ((digits == 64) ? 6 : \
+        ((digits == 128) ? 7 : \
+         (-1))))))
+
+  static const int logBits = ZX_LOG_DIGITS(bitsPerWord);
+  static const int bitsMask = (1 << logBits) - 1;
+
+public:
+  BitMatrix(int dimension);
+  BitMatrix(int width, int height);
+
+  ~BitMatrix();
+
+  bool get(int x, int y) const {
+    int offset = y * rowSize + (x >> logBits);
+    return ((((unsigned)bits[offset]) >> (x & bitsMask)) & 1) != 0;
+  }
+
+  void set(int x, int y) {
+    int offset = y * rowSize + (x >> logBits);
+    bits[offset] |= 1 << (x & bitsMask);
+  }
+
+  void flip(int x, int y);
+  void clear();
+  void setRegion(int left, int top, int width, int height);
+  Ref<BitArray> getRow(int y, Ref<BitArray> row);
+
+  int getWidth() const;
+  int getHeight() const;
+
+  ArrayRef<int> getTopLeftOnBit() const;
+  ArrayRef<int> getBottomRightOnBit() const;
+
+  friend std::ostream& operator<<(std::ostream &out, const BitMatrix &bm);
+  const char *description();
+
+private:
+  inline void init(int, int);
+
+  BitMatrix(const BitMatrix&);
+  BitMatrix& operator =(const BitMatrix&);
+};
+
+}
+
+#endif // __BIT_MATRIX_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/Counted.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,140 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __COUNTED_H__
+#define __COUNTED_H__
+
+/*
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+
+namespace zxing {
+
+/* base class for reference-counted objects */
+class Counted {
+private:
+  unsigned int count_;
+public:
+  Counted() :
+      count_(0) {
+  }
+  virtual ~Counted() {
+  }
+  Counted *retain() {
+    count_++;
+    return this;
+  }
+  void release() {
+    count_--;
+    if (count_ == 0) {
+      count_ = 0xDEADF001;
+      delete this;
+    }
+  }
+
+
+  /* return the current count for denugging purposes or similar */
+  int count() const {
+    return count_;
+  }
+};
+
+/* counting reference to reference-counted objects */
+template<typename T> class Ref {
+private:
+public:
+  T *object_;
+  explicit Ref(T *o = 0) :
+      object_(0) {
+    reset(o);
+  }
+  Ref(const Ref &other) :
+      object_(0) {
+    reset(other.object_);
+  }
+
+  template<class Y>
+  Ref(const Ref<Y> &other) :
+      object_(0) {
+    reset(other.object_);
+  }
+
+  ~Ref() {
+    if (object_) {
+      object_->release();
+    }
+  }
+
+  void reset(T *o) {
+    if (o) {
+      o->retain();
+    }
+    if (object_ != 0) {
+      object_->release();
+    }
+    object_ = o;
+  }
+  Ref& operator=(const Ref &other) {
+    reset(other.object_);
+    return *this;
+  }
+  template<class Y>
+  Ref& operator=(const Ref<Y> &other) {
+    reset(other.object_);
+    return *this;
+  }
+  Ref& operator=(T* o) {
+    reset(o);
+    return *this;
+  }
+  template<class Y>
+  Ref& operator=(Y* o) {
+    reset(o);
+    return *this;
+  }
+
+  T& operator*() {
+    return *object_;
+  }
+  T* operator->() const {
+    return object_;
+  }
+  operator T*() const {
+    return object_;
+  }
+
+  bool operator==(const T* that) {
+    return object_ == that;
+  }
+  bool operator==(const Ref &other) const {
+    return object_ == other.object_ || *object_ == *(other.object_);
+  }
+  template<class Y>
+  bool operator==(const Ref<Y> &other) const {
+    return object_ == other.object_ || *object_ == *(other.object_);
+  }
+
+  bool operator!=(const T* that) {
+    return !(*this == that);
+  }
+
+  bool empty() const {
+    return object_ == 0;
+  }
+};
+
+}
+
+#endif // __COUNTED_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/DecoderResult.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,51 @@
+#ifndef __DECODER_RESULT_H__
+#define __DECODER_RESULT_H__
+
+/*
+ *  DecoderResult.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+#include <zxing/common/Array.h>
+#include <string>
+#include <zxing/common/Str.h>
+
+namespace zxing {
+
+class DecoderResult : public Counted {
+private:
+  ArrayRef<char> rawBytes_;
+  Ref<String> text_;
+  ArrayRef< ArrayRef<char> > byteSegments_;
+  std::string ecLevel_;
+
+public:
+  DecoderResult(ArrayRef<char> rawBytes,
+                Ref<String> text,
+                ArrayRef< ArrayRef<char> >& byteSegments,
+                std::string const& ecLevel);
+
+  DecoderResult(ArrayRef<char> rawBytes, Ref<String> text);
+
+  ArrayRef<char> getRawBytes();
+  Ref<String> getText();
+};
+
+}
+
+#endif // __DECODER_RESULT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/GlobalHistogramBinarizer.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,48 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __GLOBALHISTOGRAMBINARIZER_H__
+#define __GLOBALHISTOGRAMBINARIZER_H__
+/*
+ *  GlobalHistogramBinarizer.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/Binarizer.h>
+#include <zxing/common/BitArray.h>
+#include <zxing/common/BitMatrix.h>
+#include <zxing/common/Array.h>
+
+namespace zxing {
+	
+class GlobalHistogramBinarizer : public Binarizer {
+private:
+  ArrayRef<char> luminances;
+  ArrayRef<int> buckets;
+public:
+  GlobalHistogramBinarizer(Ref<LuminanceSource> source);
+  virtual ~GlobalHistogramBinarizer();
+		
+  virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
+  virtual Ref<BitMatrix> getBlackMatrix();
+  static int estimateBlackPoint(ArrayRef<int> const& buckets);
+  Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source);
+private:
+  void initArrays(int luminanceSize);
+};
+
+}
+	
+#endif /* GLOBALHISTOGRAMBINARIZER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/HybridBinarizer.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,67 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __HYBRIDBINARIZER_H__
+#define __HYBRIDBINARIZER_H__
+/*
+ *  HybridBinarizer.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vector>
+#include <zxing/Binarizer.h>
+#include <zxing/common/GlobalHistogramBinarizer.h>
+#include <zxing/common/BitArray.h>
+#include <zxing/common/BitMatrix.h>
+
+namespace zxing {
+	
+	class HybridBinarizer : public GlobalHistogramBinarizer {
+	 private:
+    Ref<BitMatrix> matrix_;
+	  Ref<BitArray> cached_row_;
+
+	public:
+		HybridBinarizer(Ref<LuminanceSource> source);
+		virtual ~HybridBinarizer();
+		
+		virtual Ref<BitMatrix> getBlackMatrix();
+		Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source);
+  private:
+    // We'll be using one-D arrays because C++ can't dynamically allocate 2D
+    // arrays
+    ArrayRef<int> calculateBlackPoints(ArrayRef<char> luminances,
+                                       int subWidth,
+                                       int subHeight,
+                                       int width,
+                                       int height);
+    void calculateThresholdForBlock(ArrayRef<char> luminances,
+                                    int subWidth,
+                                    int subHeight,
+                                    int width,
+                                    int height,
+                                    ArrayRef<int> blackPoints,
+                                    Ref<BitMatrix> const& matrix);
+    void thresholdBlock(ArrayRef<char>luminances,
+                        int xoffset,
+                        int yoffset,
+                        int threshold,
+                        int stride,
+                        Ref<BitMatrix> const& matrix);
+	};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/IllegalArgumentException.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,36 @@
+#ifndef __ILLEGAL_ARGUMENT_EXCEPTION_H__
+#define __ILLEGAL_ARGUMENT_EXCEPTION_H__
+
+/*
+ *  IllegalArgumentException.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/Exception.h>
+
+namespace zxing {
+
+class IllegalArgumentException : public Exception {
+public:
+  IllegalArgumentException();
+  IllegalArgumentException(const char *msg);
+  ~IllegalArgumentException() throw();
+};
+
+}
+
+#endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/Str.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,51 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __STR_H__
+#define __STR_H__
+
+/*
+ *  Str.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+#include <iostream>
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+class String;
+std::ostream& operator << (std::ostream& out, String const& s);
+
+class String : public Counted {
+private:
+  std::string text_;
+public:
+  explicit String(const std::string &text);
+  explicit String(int);
+  char charAt(int) const;
+  Ref<String> substring(int) const;
+  const std::string& getText() const;
+  int size() const;
+  void append(std::string const& tail);
+  void append(char c);
+  int length() const;
+  friend std::ostream& zxing::operator << (std::ostream& out, String const& s);
+};
+
+}
+
+#endif // __COMMON__STRING_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/reedsolomon/GenericGF.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,73 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+/*
+ *  GenericGF.h
+ *  zxing
+ *
+ *  Created by Lukas Stabe on 13/02/2012.
+ *  Copyright 2012 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GENERICGF_H
+#define GENERICGF_H
+
+#include <vector>
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+  class GenericGFPoly;
+  
+  class GenericGF : public Counted {
+    
+  private:
+    std::vector<int> expTable;
+    std::vector<int> logTable;
+    Ref<GenericGFPoly> zero;
+    Ref<GenericGFPoly> one;
+    int size;
+    int primitive;
+    int generatorBase;
+    bool initialized;
+    
+    void initialize();
+    void checkInit();
+    
+  public:
+    static Ref<GenericGF> AZTEC_DATA_12;
+    static Ref<GenericGF> AZTEC_DATA_10;
+    static Ref<GenericGF> AZTEC_DATA_8;
+    static Ref<GenericGF> AZTEC_DATA_6;
+    static Ref<GenericGF> AZTEC_PARAM;
+    static Ref<GenericGF> QR_CODE_FIELD_256;
+    static Ref<GenericGF> DATA_MATRIX_FIELD_256;
+    static Ref<GenericGF> MAXICODE_FIELD_64;
+    
+    GenericGF(int primitive, int size, int b);
+    
+    Ref<GenericGFPoly> getZero();
+    Ref<GenericGFPoly> getOne();
+    int getSize();
+    int getGeneratorBase();
+    Ref<GenericGFPoly> buildMonomial(int degree, int coefficient);
+    
+    static int addOrSubtract(int a, int b);
+    int exp(int a);
+    int log(int a);
+    int inverse(int a);
+    int multiply(int a, int b);
+  };
+}
+
+#endif //GENERICGF_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/reedsolomon/GenericGFPoly.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,56 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+/*
+ *  GenericGFPoly.h
+ *  zxing
+ *
+ *  Created by Lukas Stabe on 13/02/2012.
+ *  Copyright 2012 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GENERICGFPOLY_H
+#define GENERICGFPOLY_H
+
+#include <vector>
+#include <zxing/common/Array.h>
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+class GenericGF;
+  
+class GenericGFPoly : public Counted {
+private:
+  GenericGF &field_;
+  ArrayRef<int> coefficients_;
+    
+public:
+  GenericGFPoly(GenericGF &field, ArrayRef<int> coefficients);
+  ArrayRef<int> getCoefficients();
+  int getDegree();
+  bool isZero();
+  int getCoefficient(int degree);
+  int evaluateAt(int a);
+  Ref<GenericGFPoly> addOrSubtract(Ref<GenericGFPoly> other);
+  Ref<GenericGFPoly> multiply(Ref<GenericGFPoly> other);
+  Ref<GenericGFPoly> multiply(int scalar);
+  Ref<GenericGFPoly> multiplyByMonomial(int degree, int coefficient);
+  std::vector<Ref<GenericGFPoly> > divide(Ref<GenericGFPoly> other);
+    
+
+};
+
+}
+
+#endif //GENERICGFPOLY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/common/reedsolomon/ReedSolomonDecoder.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,49 @@
+#ifndef __REED_SOLOMON_DECODER_H__
+#define __REED_SOLOMON_DECODER_H__
+
+/*
+ *  ReedSolomonDecoder.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <memory>
+#include <vector>
+#include <zxing/common/Counted.h>
+#include <zxing/common/Array.h>
+#include <zxing/common/reedsolomon/GenericGFPoly.h>
+#include <zxing/common/reedsolomon/GenericGF.h>
+
+namespace zxing {
+class GenericGFPoly;
+class GenericGF;
+
+class ReedSolomonDecoder {
+private:
+  Ref<GenericGF> field;
+public:
+  ReedSolomonDecoder(Ref<GenericGF> fld);
+  ~ReedSolomonDecoder();
+  void decode(ArrayRef<int> received, int twoS);
+  std::vector<Ref<GenericGFPoly> > runEuclideanAlgorithm(Ref<GenericGFPoly> a, Ref<GenericGFPoly> b, int R);
+
+private:
+  ArrayRef<int> findErrorLocations(Ref<GenericGFPoly> errorLocator);
+  ArrayRef<int> findErrorMagnitudes(Ref<GenericGFPoly> errorEvaluator, ArrayRef<int> errorLocations);
+};
+}
+
+#endif // __REED_SOLOMON_DECODER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/multi/ByQuadrantReader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,42 @@
+#ifndef __BY_QUADRANT_READER_H__
+#define __BY_QUADRANT_READER_H__
+
+/*
+ *  Copyright 2011 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/Reader.h>
+#include <zxing/BinaryBitmap.h>
+#include <zxing/Result.h>
+#include <zxing/DecodeHints.h>
+
+namespace zxing {
+namespace multi {
+
+class ByQuadrantReader : public Reader {
+  private:
+    Reader& delegate_;
+
+  public:
+    ByQuadrantReader(Reader& delegate);
+    virtual ~ByQuadrantReader();
+    virtual Ref<Result> decode(Ref<BinaryBitmap> image);
+    virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
+};
+
+}
+}
+
+#endif // __BY_QUADRANT_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/multi/GenericMultipleBarcodeReader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,51 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __GENERIC_MULTIPLE_BARCODE_READER_H__
+#define __GENERIC_MULTIPLE_BARCODE_READER_H__
+
+/*
+ *  Copyright 2011 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/multi/MultipleBarcodeReader.h>
+#include <zxing/Reader.h>
+
+namespace zxing {
+namespace multi {
+
+class GenericMultipleBarcodeReader : public MultipleBarcodeReader {
+ private:
+  static Ref<Result> translateResultPoints(Ref<Result> result, 
+                                           int xOffset, 
+                                           int yOffset);
+  void doDecodeMultiple(Ref<BinaryBitmap> image, 
+                        DecodeHints hints, 
+                        std::vector<Ref<Result> >& results, 
+                        int xOffset, 
+                        int yOffset,
+                        int currentDepth);
+  Reader& delegate_;
+  static const int MIN_DIMENSION_TO_RECUR = 100;
+  static const int MAX_DEPTH = 4;
+
+ public:
+  GenericMultipleBarcodeReader(Reader& delegate);
+  virtual ~GenericMultipleBarcodeReader();
+  virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image, DecodeHints hints);
+};
+
+}
+}
+
+#endif // __GENERIC_MULTIPLE_BARCODE_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/multi/MultipleBarcodeReader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,41 @@
+#ifndef __MULTIPLE_BARCODE_READER_H__
+#define __MULTIPLE_BARCODE_READER_H__
+
+/*
+ *  Copyright 2011 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+#include <zxing/Result.h>
+#include <zxing/BinaryBitmap.h>
+#include <zxing/DecodeHints.h>
+#include <vector>
+
+namespace zxing {
+namespace multi {
+
+class MultipleBarcodeReader : public Counted {
+  protected:
+    MultipleBarcodeReader() {}
+  public:
+    virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image);
+    virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
+    virtual ~MultipleBarcodeReader();
+};
+
+}
+}
+
+#endif // __MULTIPLE_BARCODE_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/multi/qrcode/QRCodeMultiReader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,36 @@
+#ifndef __QRCODE_MULTI_READER_H__
+#define __QRCODE_MULTI_READER_H__
+
+/*
+ *  Copyright 2011 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/multi/MultipleBarcodeReader.h>
+#include <zxing/qrcode/QRCodeReader.h>
+
+namespace zxing {
+namespace multi {
+
+class QRCodeMultiReader: public zxing::qrcode::QRCodeReader, public MultipleBarcodeReader {
+  public:
+    QRCodeMultiReader();
+    virtual ~QRCodeMultiReader();
+    virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image, DecodeHints hints);
+};
+
+}
+}
+
+#endif // __QRCODE_MULTI_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/qrcode/QRCodeReader.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,48 @@
+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
+#ifndef __QR_CODE_READER_H__
+#define __QR_CODE_READER_H__
+
+/*
+ *  QRCodeReader.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/Reader.h>
+#include <zxing/qrcode/decoder/Decoder.h>
+#include <zxing/DecodeHints.h>
+
+namespace zxing {
+namespace qrcode {
+		
+class QRCodeReader : public Reader {
+ private:
+  Decoder decoder_;
+			
+ protected:
+  Decoder& getDecoder();
+
+ public:
+  QRCodeReader();
+  virtual ~QRCodeReader();
+			
+  Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
+};
+
+}
+}
+
+#endif // __QR_CODE_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_lib/zxing/qrcode/decoder/Decoder.h	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,46 @@
+#ifndef __DECODER_H__
+#define __DECODER_H__
+
+/*
+ *  Decoder.h
+ *  zxing
+ *
+ *  Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
+#include <zxing/common/Counted.h>
+#include <zxing/common/Array.h>
+#include <zxing/common/DecoderResult.h>
+#include <zxing/common/BitMatrix.h>
+
+namespace zxing {
+namespace qrcode {
+
+class Decoder {
+private:
+  ReedSolomonDecoder rsDecoder_;
+
+  void correctErrors(ArrayRef<char> bytes, int numDataCodewords);
+
+public:
+  Decoder();
+  Ref<DecoderResult> decode(Ref<BitMatrix> bits);
+};
+
+}
+}
+
+#endif // __DECODER_H__
Binary file zxing_lib/zxing_lib.ar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zxing_main.cpp	Thu Oct 06 18:00:30 2016 +0900
@@ -0,0 +1,434 @@
+
+#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
+/*****************************/
+
+#if LCD_ONOFF
+/** LCD shield config **/
+#if (LCD_TYPE == 0)
+  #include "LCD_shield_config_4_3inch.h"
+#else
+  #include "LCD_shield_config_7_1inch.h"
+#endif
+#endif
+
+/** Video and Grapics (GRAPHICS_LAYER_0) parameter **/
+/* video input */
+#if USE_VIDEO_CH == (0)
+  #define VIDEO_INPUT_CH       (DisplayBase::VIDEO_INPUT_CHANNEL_0)
+  #define VIDEO_INT_TYPE       (DisplayBase::INT_TYPE_S0_VFIELD)
+#else
+  #define VIDEO_INPUT_CH       (DisplayBase::VIDEO_INPUT_CHANNEL_1)
+  #define VIDEO_INT_TYPE       (DisplayBase::INT_TYPE_S1_VFIELD)
+#endif
+
+/* NTSC or PAL */
+#if VIDEO_PAL == 0
+  #define COL_SYS              (DisplayBase::COL_SYS_NTSC_358)
+#else
+  #define COL_SYS              (DisplayBase::COL_SYS_PAL_443)
+#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)
+
+/* 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
+#else
+  #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
+
+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 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 void Init_LCD_Display(void) {
+    DisplayBase::graphics_error_t error;
+    DisplayBase::lcd_config_t lcd_config;
+    PinName lvds_pin[8] = {
+        /* data pin */
+        P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
+    };
+
+    lcd_pwon = 0;
+    lcd_blon = 0;
+    Thread::wait(100);
+    lcd_pwon = 1;
+    lcd_blon = 1;
+
+    Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
+
+    /* Graphics initialization process */
+    lcd_config = LcdCfgTbl_LCD_shield;
+    error = Display.Graphics_init(&lcd_config);
+    if (error != DisplayBase::GRAPHICS_OK) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+    graphics_init_end = true;
+}
+
+static void Start_LCD_Display(uint8_t * p_buf) {
+    DisplayBase::rect_t rect;
+
+    rect.vs = 0;
+    rect.vw = VIDEO_PIXEL_VW;
+    rect.hs = 0;
+    rect.hw = VIDEO_PIXEL_HW;
+    Display.Graphics_Read_Setting(
+        DisplayBase::GRAPHICS_LAYER_0,
+        (void *)p_buf,
+        FRAME_BUFFER_STRIDE,
+        GRAPHICS_FORMAT,
+        WR_RD_WRSWA,
+        &rect
+    );
+    Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
+}
+#endif
+
+/****** Video ******/
+static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
+    /* Interrupt callback function for Vfield interruption */
+    if (vfield_count > 0) {
+        vfield_count--;
+    }
+}
+
+static void Wait_Vfield(const int32_t wait_count) {
+    /* Wait for the specified number of times Vsync occurs */
+    vfield_count = wait_count;
+    while (vfield_count > 0) {
+        Thread::wait(1);
+    }
+}
+
+static void Init_Video(void) {
+    DisplayBase::graphics_error_t error;
+
+    /* Graphics initialization process */
+    if (graphics_init_end == false) {
+        /* When not initializing LCD, this processing is needed. */
+        error = Display.Graphics_init(NULL);
+        if (error != DisplayBase::GRAPHICS_OK) {
+            printf("Line %d, error %d\n", __LINE__, error);
+            mbed_die();
+        }
+        graphics_init_end = true;
+    }
+
+#if VIDEO_INPUT_METHOD == VIDEO_CVBS
+    error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_VDEC, NULL);
+    if( error != DisplayBase::GRAPHICS_OK ) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+#elif VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA
+    DisplayBase::video_ext_in_config_t ext_in_config;
+    PinName cmos_camera_pin[11] = {
+        /* data pin */
+        P2_7, P2_6, P2_5, P2_4, P2_3, P2_2, P2_1, P2_0,
+        /* control pin */
+        P10_0,      /* DV0_CLK   */
+        P1_0,       /* DV0_Vsync */
+        P1_1        /* DV0_Hsync */
+    };
+
+    /* MT9V111 camera input config */
+    ext_in_config.inp_format     = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */
+    ext_in_config.inp_pxd_edge   = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing data          */
+    ext_in_config.inp_vs_edge    = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing Vsync signals */
+    ext_in_config.inp_hs_edge    = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing Hsync signals */
+    ext_in_config.inp_endian_on  = DisplayBase::OFF;                      /* External input bit endian change on/off       */
+    ext_in_config.inp_swap_on    = DisplayBase::OFF;                      /* External input B/R signal swap on/off         */
+    ext_in_config.inp_vs_inv     = DisplayBase::SIG_POL_NOT_INVERTED;     /* External input DV_VSYNC inversion control     */
+    ext_in_config.inp_hs_inv     = DisplayBase::SIG_POL_INVERTED;         /* External input DV_HSYNC inversion control     */
+    ext_in_config.inp_f525_625   = DisplayBase::EXTIN_LINE_525;           /* Number of lines for BT.656 external input */
+    ext_in_config.inp_h_pos      = DisplayBase::EXTIN_H_POS_CRYCBY;       /* Y/Cb/Y/Cr data string start timing to Hsync reference */
+    ext_in_config.cap_vs_pos     = 6;                                     /* Capture start position from Vsync */
+    ext_in_config.cap_hs_pos     = 150;                                   /* Capture start position form Hsync */
+#if ((LCD_ONOFF) && (LCD_TYPE == 0))
+    /* The same screen ratio as the screen ratio of the LCD. */
+    ext_in_config.cap_width      = 640;                                   /* Capture width */
+    ext_in_config.cap_height     = 363;                                   /* Capture height Max 468[line]
+                                                                             Due to CMOS(MT9V111) output signal timing and VDC5 specification */
+#else
+    ext_in_config.cap_width      = 640;                                   /* Capture width */
+    ext_in_config.cap_height     = 468;                                   /* Capture height Max 468[line]
+                                                                             Due to CMOS(MT9V111) output signal timing and VDC5 specification */
+#endif
+    error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_EXT, &ext_in_config);
+    if( error != DisplayBase::GRAPHICS_OK ) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+
+    /* Camera input port setting */
+    error = Display.Graphics_Dvinput_Port_Init(cmos_camera_pin, 11);
+    if( error != DisplayBase::GRAPHICS_OK ) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+#endif
+
+    /* Interrupt callback function setting (Field end signal for recording function in scaler 0) */
+    error = Display.Graphics_Irq_Handler_Set(VIDEO_INT_TYPE, 0, IntCallbackFunc_Vfield);
+    if (error != DisplayBase::GRAPHICS_OK) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+}
+
+static void Start_Video(uint8_t * p_buf) {
+    DisplayBase::graphics_error_t error;
+
+    /* Video capture setting (progressive form fixed) */
+    error = Display.Video_Write_Setting(
+                VIDEO_INPUT_CH,
+                COL_SYS,
+                p_buf,
+                FRAME_BUFFER_STRIDE,
+                VIDEO_FORMAT,
+                WR_RD_WRSWA,
+                VIDEO_PIXEL_VW,
+                VIDEO_PIXEL_HW
+            );
+    if (error != DisplayBase::GRAPHICS_OK) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+
+    /* Video write process start */
+    error = Display.Video_Start(VIDEO_INPUT_CH);
+    if (error != DisplayBase::GRAPHICS_OK) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+
+    /* Video write process stop */
+    error = Display.Video_Stop(VIDEO_INPUT_CH);
+    if (error != DisplayBase::GRAPHICS_OK) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+
+    /* Video write process start */
+    error = Display.Video_Start(VIDEO_INPUT_CH);
+    if (error != DisplayBase::GRAPHICS_OK) {
+        printf("Line %d, error %d\n", __LINE__, error);
+        mbed_die();
+    }
+}
+
+/****** zxing_init ******/
+void zxing_init(void (*pfunc)(char * addr, int size)) {
+
+#if LCD_ONOFF
+    /* Initialization of LCD */
+    Init_LCD_Display();    /* When using LCD, please call before than Init_Video(). */
+#endif
+    /* 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));
+    }
+
+    /* Start of Video */
+    Start_Video(FrameBufferTbl[write_buff_num]);
+    /* Wait for first video drawing */
+    Wait_Vfield(2);
+#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;
+    /* Start of LCD */
+    Start_LCD_Display(FrameBufferTbl[write_buff_num]);
+    /* Backlight on */
+    Thread::wait(200);
+    lcd_cntrst.write(1.0);
+#endif
+    p_callback_func = pfunc;
+    decode_timer.reset();
+    decode_timer.start();
+}
+
+/****** zxing_main ******/
+int zxing_loop() {
+    DisplayBase::graphics_error_t error;
+    int decode_result = -1;
+    vector<Ref<Result> > results;
+
+    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));
+    /* 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);
+        if (decode_result == 0) {
+            char ** decode_str;
+            int     size;
+
+            decode_str = (char **)&(results[0]->getText()->getText());
+            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;
+        }
+    }
+    display_app.SendRgb888(decode_buffer, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW);
+
+    return decode_result;
+}