This is a mbed Client sample where ZXing is incorporated, and works on GR-PEACH and GR-LYCHEE.
Dependencies: DisplayApp AsciiFont
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
- GR-PEACH ( https://developer.mbed.org/platforms/Renesas-GR-PEACH/ )
- Audio Camera Shield ( https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield )
- LCD Shield ( https://developer.mbed.org/teams/Renesas/wiki/LCD-shield )
- Ethernet cable and connection to the internet
- Wireless Camera shieled (This is GR-PEACH' Wifi(ESP32) optional.)
- GR-LYCHEE ( https://developer.mbed.org/platforms/Renesas-GR-LYCHEE/ )
Application setup
- Select the connection type. For details, please refer to the following wiki:
https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Connection-type. - Set the client credentials. For details, please refer to the following wiki:
https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Client-credentials. - Change Ethernet settings. For details, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Ethernet-settings. - Change Wifi settings. For details, please refer to the following wiki:
https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Wifi-settings. - Set up an IP address. (This step is optional.) For details, please refer to the following wiki:
https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/IP-address-setup.
Building the example
To build this example:
- Import this example onto mbed Compiler.
- Configure the example in accordance with Application setup.
- Compile the example on mbed Compiler and download the resultant binary file.
- Plug the Ethernet cable into GR-PEACH or GR-LYCHEE if you are using Ethernet mode.
- Plug the micro-USB cable into the OpenSDA port which lies on the next to the RESET button.
- Copy the binary previously downloaded to your PC to GR-PEACH or GR-LYCHEE to flash this example. When the copy is successfully completed, the board is ready to work.
- Press the RESET button on the board to run the example.
- For verification, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Monitoring-the-application.
Application resources
This example exposes four resources listed below:
- 3202/0/5700. Decode result of barcode data input from camera (GET).
- 3201/0/5850. Blink function, blinks LED when executed (POST).
- 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).
- 3201/0/5855. Blink color, used by the blink function. Any of red, green, blue, cyan, yellow and magenta is acceptable if you are using GR-PEACH board (PUT).
- 3201/0/5855. Blink color, used by the blink function. Any of green, yellow, orange and red is acceptable if you are using GR-LYCHEE board (PUT).
For more info on how to get notifications when resource 1 changes, or how to use resource 2, 3 and 4, please look at
Import programGR-PEACH_mbed-connector-ZXingSample-node
Node.js based Web Application for mbed Device Connector specific to GR-PEACH_mbed-os-client-ZXingSample
Revision 6:ea24d9271ff1, committed 2018-12-13
- Comitter:
- 1050186
- Date:
- Thu Dec 13 08:28:47 2018 +0000
- Parent:
- 5:6b6540e303f2
- Child:
- 7:f9c1728de5c5
- Commit message:
- Update each library(Mbed OS 5.9.7, mbed-os-client).
Changed in this revision
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
--- a/README.md Mon Apr 17 05:28:29 2017 +0000
+++ b/README.md Thu Dec 13 08:28:47 2018 +0000
@@ -40,7 +40,6 @@
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
@@ -80,72 +79,12 @@
}
```
-### 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_ESP8266, WIFI_BP3595, NO_CONNECT",
- "value": "WIFI_BP3595"
- },
-```
-
-Provide your WiFi SSID and password here and leave `\"` in the beginning and end of your SSID and password (as shown in the example below). Otherwise, the example cannot pick up the SSID and password in correct format.
-```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_WPA_WPA2 is specified. That means WPA and WPA2 are available. If you would like to use WEP instead of WPA2, please specify NSAPI_SECURITY_WEP here.
-```json
- "wifi-security": {
- "help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
- "value": "NSAPI_SECURITY_WPA_WPA2"
- }
-```
-
-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 IP address from the router when connected over Ethernet or WiFi.
If your network does not have DHCP enabled, you have to manually assign a static IP address to the board. We recommend having DHCP enabled to make everything run smoothly.
-### Changing socket type
-
-Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default and only allowed value is UDP for Thread and 6LoWPAN. TCP is the default for other connections. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.
-
-To change the binding mode:
-
-1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP` for mesh and `M2MInterface::TCP` for others.
-1. To switch to UDP, change it to `M2MInterface::UDP`.
-1. Rebuild and flash the application.
-
-<span class="tips">**Tip:** The instructions in this document remain the same, irrespective of the socket mode you select.</span>
-
-Possible socket types per connection:
-
-| Network interface | UDP | TCP |
-| ------------------------------|:-----:|:-----:|
-| Ethernet (IPv4) | X | X |
-| Ethernet (IPv6) | X | |
-| Wifi (IPv4) | X | X |
-| Wifi (IPv6) - Not supported | | |
-| 6LoWPAN/Thread (IPv6) | X | |
-
## Building the example
To build the example using mbed CLI:
@@ -170,7 +109,7 @@
5. Plug the micro-USB cable into the **OpenSDA** port. The board is listed as a mass-storage device.
-6. Drag the binary `BUILD/RZ_A1H/GCC_ARM/GR-PEACH_mbed-os-client-ZXingSample.bin` to the board to flash the application.
+6. Drag the binary `BUILD/RZ_A1H/GCC_ARM/XXXXXXXX.bin` to the board to flash the application.
7. The board is automatically programmed with the new binary. A flashing LED on it indicates that it is still working. When the LED stops blinking, the board is ready to work.
@@ -186,17 +125,16 @@
```
-Starting mbed Client example in IPv4 mode
+Starting mbed Client example
[EasyConnect] Using Ethernet
[EasyConnect] Connected to Network successfully
-[EasyConnect] IP address 192.168.8.110
-[EasyConnect] MAC address 5c:cf:7f:86:de:bf
+[EasyConnect] IP address xxx.xxx.xxx.xxx
+[EasyConnect] MAC address xx:xx:xx:xx:xx:xx
SOCKET_MODE : TCP
-
Connecting to coap://api.connector.mbed.com:5684
-Registered object succesfully!
+Registered object successfully!
```
<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>
@@ -212,7 +150,6 @@
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.

--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/cellular_c030_u201.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,23 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, WIFI_RTW, MESH_LOWPAN_ND, MESH_THREAD, CELLULAR_ONBOARD",
+ "value": "CELLULAR_ONBOARD"
+ },
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["LWIP", "COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines":true,
+ "lwip.ipv4-enabled": true,
+ "lwip.ipv6-enabled": false,
+ "mbed-trace.enable": 0
+ },
+ "UBLOX_C030_U201": {
+ "lwip.ppp-enabled": true,
+ "ppp-cell-iface.apn-lookup": true
+ }
+ }
+}
--- a/configs/eth-wifi-mbedignore Mon Apr 17 05:28:29 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -easy-connect/atmel-rf-driver/* -easy-connect/mcr20a-rf-driver/* -easy-connect/stm-spirit1-rf-driver/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth_odin_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,22 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+ "value": "ETHERNET"
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["LWIP", "COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "lwip.ipv4-enabled": true,
+ "lwip.ipv6-enabled": false,
+ "mbed-trace.enable": 0
+ },
+ "UBLOX_EVK_ODIN_W2": {
+ "target.network-default-interface-type": "ETHERNET"
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth_odin_v6.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,22 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+ "value": "ETHERNET"
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["LWIP", "COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "lwip.ipv4-enabled": false,
+ "lwip.ipv6-enabled": true,
+ "mbed-trace.enable": 0
+ },
+ "UBLOX_EVK_ODIN_W2": {
+ "target.network-default-interface-type": "ETHERNET"
+ }
+ }
+}
--- a/configs/eth_v4.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/eth_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -3,6 +3,10 @@
"network-interface":{
"help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
"value": "ETHERNET"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
@@ -15,8 +19,8 @@
"lwip.ipv6-enabled": false,
"mbed-trace.enable": 0
},
- "UBLOX_EVK_ODIN_W2": {
- "target.device_has_remove": ["EMAC"]
+ "UBLOX_EVK_ODIN_W2": {
+ "target.network-default-interface-type": "ETHERNET"
}
}
}
--- a/configs/eth_v6.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/eth_v6.json Thu Dec 13 08:28:47 2018 +0000
@@ -3,6 +3,10 @@
"network-interface":{
"help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
"value": "ETHERNET"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
@@ -15,8 +19,8 @@
"lwip.ipv6-enabled": true,
"mbed-trace.enable": 0
},
- "UBLOX_EVK_ODIN_W2": {
- "target.device_has_remove": ["EMAC"]
+ "UBLOX_EVK_ODIN_W2": {
+ "target.network-default-interface-type": "ETHERNET"
}
}
}
--- a/configs/mesh-mbedignore Mon Apr 17 05:28:29 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -easy-connect/esp8266-driver/*
--- a/configs/mesh_6lowpan.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/mesh_6lowpan.json Thu Dec 13 08:28:47 2018 +0000
@@ -7,12 +7,17 @@
"mesh_radio_type": {
"help": "options are ATMEL, MCR20",
"value": "ATMEL"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
- "target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
+ "target.features_add": ["NANOSTACK", "COMMON_PAL"],
+ "nanostack.configuration": "lowpan_router",
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
"mbed-mesh-api.6lowpan-nd-channel-page": 0,
--- a/configs/mesh_6lowpan_subg.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/mesh_6lowpan_subg.json Thu Dec 13 08:28:47 2018 +0000
@@ -7,13 +7,18 @@
"mesh_radio_type": {
"help": "options are ATMEL, MCR20, SPIRIT1",
"value": "SPIRIT1"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
"spirit1.mac-address": "{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7}",
- "target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
+ "target.features_add": ["NANOSTACK", "COMMON_PAL"],
+ "nanostack.configuration": "lowpan_router",
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
"mbed-mesh-api.6lowpan-nd-security-mode": "PSK",
--- a/configs/mesh_thread.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/mesh_thread.json Thu Dec 13 08:28:47 2018 +0000
@@ -5,14 +5,19 @@
"value": "MESH_THREAD"
},
"mesh_radio_type": {
- "help": "options are ATMEL, MCR20",
+ "help": "options are ATMEL, MCR20, EFR32",
"value": "ATMEL"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
- "target.features_add": ["NANOSTACK", "THREAD_ROUTER", "COMMON_PAL"],
+ "target.features_add": ["NANOSTACK", "COMMON_PAL"],
+ "nanostack.configuration": "thread_router",
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
"mbed-mesh-api.thread-config-channel": 22,
--- a/configs/wifi_esp8266_v4.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/wifi_esp8266_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -19,16 +19,19 @@
"wifi-rx": {
"help": "RX pin for serial connection to external device",
"value": "D0"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
- "target.features_add": ["LWIP", "COMMON_PAL"],
+ "drivers.uart-serial-rxbuf-size": 1024,
+ "target.features_add": ["COMMON_PAL"],
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
- "lwip.ipv4-enabled": true,
- "lwip.ipv6-enabled": false,
"mbed-trace.enable": 0
},
"NUCLEO_F401RE": {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_idw01m1_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,36 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_IDW0XX1, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+ "value": "WIFI_IDW0XX1"
+ },
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"Password\""
+ },
+ "wifi-tx": {
+ "help": "TX pin for serial connection to external device",
+ "value": "PA_9"
+ },
+ "wifi-rx": {
+ "help": "RX pin for serial connection to external device",
+ "value": "PA_10"
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "mbed-trace.enable": 0,
+ "idw0xx1.expansion-board": "IDW01M1",
+ "drivers.uart-serial-txbuf-size": 512,
+ "drivers.uart-serial-rxbuf-size": 512
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_idw04a1_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,36 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_IDW0XX1, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
+ "value": "WIFI_IDW0XX1"
+ },
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"Password\""
+ },
+ "wifi-tx": {
+ "help": "TX pin for serial connection to external device",
+ "value": "D8"
+ },
+ "wifi-rx": {
+ "help": "RX pin for serial connection to external device",
+ "value": "D2"
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"", "IDW04A1_WIFI_HW_BUG_WA"],
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "mbed-trace.enable": 0,
+ "idw0xx1.expansion-board": "IDW04A1",
+ "drivers.uart-serial-txbuf-size": 512,
+ "drivers.uart-serial-rxbuf-size": 512
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_ism43362.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,24 @@
+{
+ "config": {
+ "network-interface":{
+ "value": "WIFI_ISM43362"
+ },
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"PASSWORD\""
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "mbed-trace.enable": 0
+ }
+ }
+}
--- a/configs/wifi_odin_v4.json Mon Apr 17 05:28:29 2017 +0000
+++ b/configs/wifi_odin_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -12,16 +12,12 @@
"help": "WiFi Password",
"value": "\"Password\""
},
- "wifi-tx": {
- "help": "TX pin for serial connection to external device",
- "value": "D1"
- },
- "wifi-rx": {
- "help": "RX pin for serial connection to external device",
- "value": "D0"
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
}
},
- "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"", "MBED_CONF_RSA_REQUIRED"],
"target_overrides": {
"*": {
"target.features_add": ["LWIP", "COMMON_PAL"],
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_rtw_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,30 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, WIFI_RTW, MESH_LOWPAN_ND, MESH_THREAD",
+ "value": "WIFI_RTW"
+ },
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"Password\""
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "NC"
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "drivers.uart-serial-rxbuf-size": 1024,
+ "target.features_add": ["COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "mbed-trace.enable": 0
+ }
+ }
+}
--- a/configs/wifi_v4.json Mon Apr 17 05:28:29 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-{
- "config": {
- "network-interface":{
- "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
- "value": "WIFI_ESP8266"
- },
- "wifi-ssid": {
- "help": "WiFi SSID",
- "value": "\"SSID\""
- },
- "wifi-password": {
- "help": "WiFi Password",
- "value": "\"Password\""
- },
- "wifi-tx": {
- "help": "TX pin for serial connection to external device",
- "value": "D1"
- },
- "wifi-rx": {
- "help": "RX pin for serial connection to external device",
- "value": "D0"
- }
- },
- "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
- "target_overrides": {
- "*": {
- "target.features_add": ["LWIP", "COMMON_PAL"],
- "platform.stdio-baud-rate": 115200,
- "platform.stdio-convert-newlines": true,
- "lwip.ipv4-enabled": true,
- "lwip.ipv6-enabled": false,
- "mbed-trace.enable": 0
- },
- "NUCLEO_F401RE": {
- "wifi-tx": "PA_11",
- "wifi-rx": "PA_12"
- },
- "NUCLEO_F411RE": {
- "wifi-tx": "PA_11",
- "wifi-rx": "PA_12"
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_wizfi310_v4.json Thu Dec 13 08:28:47 2018 +0000
@@ -0,0 +1,47 @@
+{
+ "config": {
+ "network-interface":{
+ "help": "Options are ETHERNET, WIFI_IDW0XX1, WIFI_ESP8266, WIFI_ODIN, WIFI_WIZFI310, MESH_LOWPAN_ND, MESH_THREAD, CELLULAR_ONBOARD",
+ "value": "WIFI_WIZFI310"
+ },
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"Password\""
+ },
+ "wifi-tx": {
+ "help": "TX pin for serial connection to external device",
+ "value": "D1"
+ },
+ "wifi-rx": {
+ "help": "RX pin for serial connection to external device",
+ "value": "D0"
+ },
+ "button1": {
+ "help": "Use BUTTON1 from PinNames.h by default",
+ "value": "BUTTON1"
+ }
+ },
+ "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
+ "target_overrides": {
+ "*": {
+ "drivers.uart-serial-rxbuf-size": 1024,
+ "target.features_add": ["COMMON_PAL"],
+ "platform.stdio-baud-rate": 115200,
+ "platform.stdio-convert-newlines": true,
+ "mbed-trace.enable": 0
+ },
+ "NUCLEO_F401RE": {
+ "wifi-tx": "PA_11",
+ "wifi-rx": "PA_12"
+ },
+ "NUCLEO_F411RE": {
+ "wifi-tx": "PA_11",
+ "wifi-rx": "PA_12"
+ }
+ }
+}
+
--- a/main.cpp Mon Apr 17 05:28:29 2017 +0000
+++ b/main.cpp Thu Dec 13 08:28:47 2018 +0000
@@ -45,17 +45,73 @@
#else // MBED_CONF_APP_NETWORK_INTERFACE != NO_CONNECT
#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
#include <string>
#include <sstream>
#include <vector>
+#include "mbed-trace/mbed_trace.h"
+#include "mbedtls/entropy_poll.h"
+
#include "security.h"
-#include "simpleclient.h"
-#include "mbedtls/entropy_poll.h"
+
+#include "mbed.h"
// easy-connect compliancy, it has 2 sets of wifi pins we have only one
#define MBED_CONF_APP_ESP8266_TX MBED_CONF_APP_WIFI_TX
#define MBED_CONF_APP_ESP8266_RX MBED_CONF_APP_WIFI_RX
-#include "easy-connect.h"
+#include "easy-connect/easy-connect.h"
+
+// Should be defined after easy-connect.h
+#include "simpleclient.h"
+
+#ifdef TARGET_STM
+#define RED_LED (LED3)
+#define GREEN_LED (LED1)
+#define BLUE_LED (LED2)
+#define LED_ON (1)
+#elif TARGET_RZ_A1H
+#define RED_LED (LED1)
+#define GREEN_LED (LED2)
+#define BLUE_LED (LED3)
+#define USER_LED (LED4)
+#define LED_ON (1)
+#elif TARGET_GR_LYCHEE
+#define GREEN_LED (LED1)
+#define YELLOW_LED (LED2)
+#define ORANGE_LED (LED3)
+#define RED_LED (LED4)
+#define LED_ON (1)
+#else
+#define RED_LED (LED1)
+#define GREEN_LED (LED2)
+#define BLUE_LED (LED3)
+#define LED_ON (0)
+#endif
+#define LED_OFF (!LED_ON)
+
+#define BLINK_SIGNAL 0x1
+
+// Status indication
+DigitalOut red_led(RED_LED);
+DigitalOut green_led(GREEN_LED);
+#ifdef TARGET_RZ_A1H
+DigitalOut blue_led(BLUE_LED);
+DigitalOut user_led(USER_LED);
+#elif TARGET_GR_LYCHEE
+DigitalOut yellow_led(YELLOW_LED);
+DigitalOut orange_led(ORANGE_LED);
+#else
+DigitalOut blue_led(BLUE_LED);
+#endif
+
+Ticker status_ticker;
+void blinky() {
+#ifdef TARGET_RZ_A1H
+ user_led = !user_led;
+#else
+ green_led = !green_led;
+#endif
+}
// These are example resource values for the Device Object
struct MbedClientDevice device = {
@@ -68,10 +124,79 @@
// Instantiate the class which implements LWM2M Client API (from simpleclient.h)
MbedClient mbed_client(device);
-// LED Output
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
-DigitalOut led3(LED3);
+// Set up a button interrupt for user interaction
+#ifdef MBED_CONF_APP_BUTTON1
+ InterruptIn counter_btn(MBED_CONF_APP_BUTTON1);
+#endif
+
+
+/**
+ * User interaction handler / simulator. Sets up physical button handler and a ticker
+ * for regular updates for the resources.
+ *
+ * MBED_CONF_APP_BUTTON1 is mapped to actual button pin the mbed_app.json file, where you need to
+ * specify board-specific value or leave it undefined if the board does not have buttons.
+ */
+class InteractionProvider {
+
+public:
+ InteractionProvider(Semaphore& updates_sem) : updates(updates_sem) {
+
+ timer_ticked = false;
+ clicked = false;
+
+ // Set up handler function for the interaction button, if available
+
+#ifdef MBED_CONF_APP_BUTTON1
+ counter_btn.fall(this, &InteractionProvider::counter_button_handler);
+#endif
+
+ // Use the counter button handler to send an update of endpoint resource values
+ // to connector every 15 seconds periodically.
+ timer.attach(this, &InteractionProvider::timer_handler, 15.0);
+ }
+
+ // flags for interaction, these are read from outside interrupt context
+ volatile bool timer_ticked;
+ volatile bool clicked;
+
+
+private:
+
+ void timer_handler() {
+ timer_ticked = true;
+ updates.release();
+ }
+
+ void counter_button_handler() {
+ clicked = true;
+ updates.release();
+ }
+
+ // time-based event source for regular resource updates
+ Ticker timer;
+
+ // Network interaction must be performed outside of interrupt context
+ Semaphore& updates;
+
+};
+
+/*
+ * Arguments for running "blink" in it's own thread.
+ */
+class BlinkArgs {
+public:
+ BlinkArgs() {
+ clear();
+ }
+ void clear() {
+ position = 0;
+ blink_pattern.clear();
+ }
+ uint16_t position;
+ std::vector<uint32_t> blink_pattern;
+};
+
/*
* The Led contains one property (pattern) and a function (blink).
* When the function blink is executed, the pattern is read, and the LED
@@ -81,6 +206,7 @@
public:
LedResource() {
// create ObjectID with metadata tag of '3201', which is 'digital output'
+// blinky_thread.start(callback(this, &LedResource::do_blink));
led_object = M2MInterfaceFactory::create_object("3201");
M2MObjectInstance* led_inst = led_object->create_object_instance();
@@ -115,8 +241,6 @@
}
void blink(void *argument) {
-
-
// read the value of 'Pattern'
M2MObjectInstance* inst = led_object->object_instance();
M2MResource* res = inst->resource("5853");
@@ -128,7 +252,7 @@
uint8_t* buffIn = NULL;
uint32_t sizeIn;
res->get_value(buffIn, sizeIn);
-
+
uint8_t* cbuffIn = NULL;
uint32_t csizeIn;
resC->get_value(cbuffIn, csizeIn);
@@ -137,12 +261,11 @@
std::string s((char*)buffIn, sizeIn);
std::vector<uint32_t>* v = new std::vector<uint32_t>;
- printf("led_execute_callback pattern=%s\r\n", s.c_str());
+ printf("led_execute_callback pattern=%s\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(":");
@@ -168,47 +291,227 @@
private:
M2MObject* led_object;
void do_blink(uint8_t* color) {
-
+
+#if defined(TARGET_RZ_A1H)
if (!strcmp((char *)color, "red")) {
// blink the LED in red color
- led1 = !led1;
+ red_led = !red_led;
}
else if (!strcmp((char *)color, "green")) {
// blink in green color
- led2 = !led2;
+ green_led = !green_led;
}
else if (!strcmp((char *)color, "blue")) {
// blink in blue color
- led3 = !led3;
+ blue_led = !blue_led;
}
else if (!strcmp((char *)color, "cyan")) {
// blink in cyan color
- led2 = !led2;
- led3 = !led3;
+ green_led = !green_led;
+ blue_led = !blue_led;
}
else if (!strcmp((char *)color, "yellow")) {
// blink in yellow color
- led1 = !led1;
- led2 = !led2;
+ red_led = !red_led;
+ green_led = !green_led;
}
else if (!strcmp((char *)color, "magenta")) {
// blink in magenta color
- led1 = !led1;
- led3 = !led3;
+ red_led = !red_led;
+ blue_led = !blue_led;
}
else if (!strcmp((char *)color, "white")) {
// blink in white color
- led1 = !led1;
- led2 = !led2;
- led3 = !led3;
+ red_led = !red_led;
+ green_led = !green_led;
+ blue_led = !blue_led;
+ }
+ else {
+ // no operation
+ }
+#elif defined(TARGET_GR_LYCHEE)
+ if (!strcmp((char *)color, "green")) {
+ // blink the LED1(green color)
+ green_led = !green_led;
+ }
+ else if (!strcmp((char *)color, "yellow")) {
+ // blink the LED2(yellow color)
+ yellow_led = !yellow_led;
+ }
+ else if (!strcmp((char *)color, "orange")) {
+ // blink the LED3(orange color)
+ orange_led = !orange_led;
+ }
+ else if (!strcmp((char *)color, "red")) {
+ // blink the LED4(red color)
+ red_led = !red_led;
}
else {
// no operation
}
+#endif
}
};
/*
+ * 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() {
+ if (mbed_client.register_successful()) {
+ M2MObjectInstance* inst = btn_object->object_instance();
+ M2MResource* res = inst->resource("5501");
+
+ // up counter
+ counter++;
+ printf("handle_button_click, new value of counter is %d\n", counter);
+ // 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);
+ } else {
+ printf("simulate button_click, device not registered\n");
+ }
+ }
+
+private:
+ M2MObject* btn_object;
+ uint16_t counter;
+};
+
+/*
+ * The timer contains one property: counter.
+ * When `handle_timer_tick` is executed, the counter updates.
+ */
+class TimerResource {
+public:
+ TimerResource(): 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 '5502', which is digital input counter
+ M2MResource* btn_res = btn_inst->create_dynamic_resource("5502", "Timer",
+ 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);
+ }
+
+ ~TimerResource() {
+ }
+
+ M2MObject* get_object() {
+ return btn_object;
+ }
+
+ /*
+ * When the timer ticks, we read the current value of the click counter
+ * from mbed Device Connector, then up the value with one.l
+ */
+ void handle_timer_tick() {
+ if (mbed_client.register_successful()) {
+ M2MObjectInstance* inst = btn_object->object_instance();
+ M2MResource* res = inst->resource("5502");
+
+ // up counter
+ counter++;
+ printf("handle_timer_click, new value of counter is %d\n", counter);
+ // 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);
+ } else {
+ printf("handle_timer_tick, device not registered\n");
+ }
+ }
+
+private:
+ M2MObject* btn_object;
+ uint16_t counter;
+};
+
+
+
+class BigPayloadResource {
+public:
+ BigPayloadResource() {
+ big_payload = M2MInterfaceFactory::create_object("1000");
+ M2MObjectInstance* payload_inst = big_payload->create_object_instance();
+ M2MResource* payload_res = payload_inst->create_dynamic_resource("1", "BigData",
+ M2MResourceInstance::STRING, true /* observable */);
+ payload_res->set_operation(M2MBase::GET_PUT_ALLOWED);
+ payload_res->set_value((uint8_t*)"0", 1);
+ payload_res->set_incoming_block_message_callback(
+ incoming_block_message_callback(this, &BigPayloadResource::block_message_received));
+ payload_res->set_outgoing_block_message_callback(
+ outgoing_block_message_callback(this, &BigPayloadResource::block_message_requested));
+ }
+
+ M2MObject* get_object() {
+ return big_payload;
+ }
+
+ void block_message_received(M2MBlockMessage *argument) {
+ if (argument) {
+ if (M2MBlockMessage::ErrorNone == argument->error_code()) {
+ if (argument->is_last_block()) {
+ printf("Last block received\n");
+ }
+ printf("Block number: %d\n", argument->block_number());
+ // First block received
+ if (argument->block_number() == 0) {
+ // Store block
+ // More blocks coming
+ } else {
+ // Store blocks
+ }
+ } else {
+ printf("Error when receiving block message! - EntityTooLarge\n");
+ }
+// printf("Total message size: %" PRIu32 "\n", argument->total_message_size());
+ printf("Total message size: %PRIu32\n", argument->total_message_size());
+ }
+ }
+
+ void block_message_requested(const String& resource, uint8_t *&/*data*/, uint32_t &/*len*/) {
+ printf("GET request received for resource: %s\n", resource.c_str());
+ // Copy data and length to coap response
+ }
+
+private:
+ M2MObject* big_payload;
+};
+
+/*
* The Zxing contains a function (send string).
* When `handle_string_send` is executed, the string after decoding is sent.
*/
@@ -239,13 +542,17 @@
* 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");
+ if (mbed_client.register_successful()) {
+ M2MObjectInstance* inst = zxing_object->object_instance();
+ M2MResource* res = inst->resource("5700");
+
+ printf("%s\r\n", addr);
- printf("%s\r\n", addr);
-
- // tell the string to connector
- res->set_value((uint8_t *)addr, size);
+ // tell the string to connector
+ res->set_value((uint8_t *)addr, size);
+ } else {
+ printf("handle_string_send, device not registered\n");
+ }
}
private:
@@ -258,10 +565,10 @@
zxing_resource.handle_string_send(addr, size);
}
-static volatile bool registered;
-void unregister() {
- registered = false;
+// debug printf function
+void trace_printer(const char* str) {
+ printf("%s\r\n", str);
}
// Entry point to the program
@@ -289,19 +596,24 @@
#endif
srand(seed);
- // Keep track of the main thread
- mainThread = osThreadGetId();
- printf("\nStarting mbed Client example in ");
-
-#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
- printf("IPv6 mode\n");
+ red_led = LED_OFF;
+#ifdef TARGET_GR_LYCHEE
+ orange_led = LED_OFF;
#else
- printf("IPv4 mode\n");
+ blue_led = LED_OFF;
#endif
- mbed_trace_init();
+ status_ticker.attach_us(blinky, 250000);
+ // Keep track of the main thread
+ osThreadId mainThread = osThreadGetId();
+
+ printf("\nStarting mbed Client example\n");
-#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI_BP3595
+ mbed_trace_init();
+ mbed_trace_print_function_set(trace_printer);
+ mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_INFO | TRACE_CARRIAGE_RETURN);
+
+#if defined(TARGET_RZ_A1H) && (MBED_CONF_APP_NETWORK_INTERFACE == WIFI_BP3595)
DigitalOut usb1en(P3_8);
usb1en = 1;
Thread::wait(5);
@@ -314,7 +626,18 @@
printf("\nConnection to Network Failed - exiting application...\n");
return -1;
}
+
+ // we create our button, timer and LED resources
+ ButtonResource button_resource;
LedResource led_resource;
+ BigPayloadResource big_payload_resource;
+ TimerResource timer_resource;
+
+ // Network interaction must be performed outside of interrupt context
+ Semaphore updates(0);
+
+ InteractionProvider interaction_provider(updates);
+
// Create endpoint interface to manage register and unregister
mbed_client.create_interface(MBED_SERVER_ADDRESS, network);
@@ -328,7 +651,10 @@
// Add objects to list
object_list.push_back(device_object);
+ object_list.push_back(button_resource.get_object());
object_list.push_back(led_resource.get_object());
+ object_list.push_back(big_payload_resource.get_object());
+ object_list.push_back(timer_resource.get_object());
object_list.push_back(zxing_resource.get_object());
// Set endpoint registration object
@@ -336,18 +662,16 @@
// Register with mbed Device Connector
mbed_client.test_register(register_object, object_list);
+ volatile bool registered = true;
+#if defined(TARGET_RZ_A1H) || defined(TARGET_GR_LYCHEE)
zxing_init(&callback_zxing);
Timer update_timer;
update_timer.reset();
update_timer.start();
- registered = true;
- InterruptIn unreg_button(USER_BUTTON0);
- unreg_button.fall(&unregister);
-
- while (registered) {
+ while (true) {
if (zxing_loop() == 0) {
update_timer.reset();
} else if (update_timer.read() >= 25) {
@@ -358,10 +682,39 @@
}
Thread::wait(5);
}
+#else
+ while (true) {
+ updates.wait(25000);
+ if(registered) {
+ if(!interaction_provider.clicked) {
+ mbed_client.test_update_register();
+ }
+ }else {
+ break;
+ }
+ if(interaction_provider.clicked) {
+ interaction_provider.clicked = false;
+ button_resource.handle_button_click();
+ }
+ if(interaction_provider.timer_ticked) {
+ interaction_provider.timer_ticked = false;
+ timer_resource.handle_timer_tick();
+ }
+ }
+#endif
mbed_client.test_unregister();
+ status_ticker.detach();
}
+void mbed_mac_address(char *mac) {
+ mac[0] = 0x00;
+ mac[1] = 0x02;
+ mac[2] = 0xF7;
+ mac[3] = 0xF0;
+ mac[4] = 0x00;
+ mac[5] = 0x00;
+}
#endif // MBED_CONF_APP_NETWORK_INTERFACE != NO_CONNECT
--- a/mbed-client.lib Mon Apr 17 05:28:29 2017 +0000 +++ b/mbed-client.lib Thu Dec 13 08:28:47 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-client/#26ed79aa6cb88eead7ee0fe97ab5fbe8fa3a0b5e +https://github.com/ARMmbed/mbed-client/#ea04c5de78225e88f90868ddd4cf10438b0ad1b3
--- a/mbed-os.lib Mon Apr 17 05:28:29 2017 +0000 +++ b/mbed-os.lib Thu Dec 13 08:28:47 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#42be5c01a7f91292d5e27124ad9584236025f6ab +https://github.com/ARMmbed/mbed-os/#949cb49ab0a144da0e3b04b6af46db0cd2a20d75
--- a/mbed_app.json Mon Apr 17 05:28:29 2017 +0000
+++ b/mbed_app.json Thu Dec 13 08:28:47 2018 +0000
@@ -1,9 +1,13 @@
{
"config": {
"network-interface":{
- "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595, NO_CONNECT",
+ "help": "Options are ETHERNET, WIFI_IDW0XX1, WIFI_ESP8266, WIFI_BP3595, WIFI_ESP32, WIFI_ISM43362, WIFI_ODIN, WIFI_WIZFI310, MESH_LOWPAN_ND, MESH_THREAD, CELLULAR_ONBOARD, NO_CONNECT",
"value": "NO_CONNECT"
},
+ "mesh_radio_type": {
+ "help": "options are ATMEL, MCR20, SPIRIT1, EFR32",
+ "value": "ATMEL"
+ },
"wifi-ssid": {
"help": "WiFi SSID",
"value": "\"SSID\""
@@ -23,16 +27,41 @@
"wifi-rx": {
"help": "RX pin for serial connection to external device",
"value": "D0"
+ },
+ "camera":{
+ "help": "0:disable 1:enable",
+ "value": "1"
+ },
+ "camera-type":{
+ "help": "Options are CAMERA_CVBS, CAMERA_MT9V111, CAMERA_OV7725",
+ "value": "CAMERA_MT9V111"
+ },
+ "lcd":{
+ "help": "0:disable 1:enable",
+ "value": "1"
+ },
+ "lcd-type":{
+ "help": "Options are GR_PEACH_4_3INCH_SHIELD, GR_PEACH_7_1INCH_SHIELD, GR_PEACH_RSK_TFT, GR_PEACH_DISPLAY_SHIELD, GR_LYCHEE_LCD",
+ "value": "GR_PEACH_4_3INCH_SHIELD"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
- "target.features_add": ["COMMON_PAL"],
+ "target.features_add": ["NANOSTACK", "COMMON_PAL"],
+ "nanostack.configuration": "lowpan_router",
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
+ "mbed-mesh-api.6lowpan-nd-channel-page": 0,
+ "mbed-mesh-api.6lowpan-nd-channel": 12,
"mbed-trace.enable": 0
},
+ "DISCO_F413ZH": {
+ "network-interface": "WIFI_ISM43362"
+ },
+ "DISCO_L475VG_IOT01A": {
+ "network-interface": "WIFI_ISM43362"
+ },
"NUCLEO_F401RE": {
"wifi-tx": "PA_11",
"wifi-rx": "PA_12"
@@ -45,9 +74,11 @@
"target.macros_add": ["MBEDTLS_TEST_NULL_ENTROPY", "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES"]
},
"UBLOX_EVK_ODIN_W2": {
- "target.device_has_remove": ["EMAC"]
+ "target.network-default-interface-type": "ETHERNET"
+ },
+ "UBLOX_C030_U201": {
+ "lwip.ppp-enabled": true,
+ "ppp-cell-iface.apn-lookup": true
}
}
}
-
-
--- a/mbed_client_config.h Mon Apr 17 05:28:29 2017 +0000 +++ b/mbed_client_config.h Thu Dec 13 08:28:47 2018 +0000 @@ -37,7 +37,7 @@ // 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 +#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 512 // 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
--- a/mbedtls_mbed_client_config.h Mon Apr 17 05:28:29 2017 +0000 +++ b/mbedtls_mbed_client_config.h Thu Dec 13 08:28:47 2018 +0000 @@ -77,9 +77,17 @@ #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 RSA, save 20KB at total. +// However, with Mbed OS 5.9 onwards - UBLOX_EVK_ODIN_W2 must have RSA! +// A more abstract macro define added for that which you can trigger via +// macros -part in the mbed_app.json. +#if !defined(MBED_CONF_RSA_REQUIRED) + #undef MBEDTLS_RSA_C + #undef MBEDTLS_PK_RSA_ALT_SUPPORT + #undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + #undef MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + #undef MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +#endif // !MBED_CONF_RSA_REQUIRED // Remove error messages, save 10KB of ROM #undef MBEDTLS_ERROR_C
--- a/pal.lib Mon Apr 17 05:28:29 2017 +0000 +++ b/pal.lib Thu Dec 13 08:28:47 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/pal/#4e46c0ea870631bb5bec3e4aa9fd7eebf3db21f0 +https://github.com/ARMmbed/pal/#60ce64d5ec358b3cf8bb492b95c5da7dad9254ca
--- a/simpleclient.h Mon Apr 17 05:28:29 2017 +0000
+++ b/simpleclient.h Thu Dec 13 08:28:47 2018 +0000
@@ -29,23 +29,10 @@
#include "security.h"
#include "mbed.h"
-#define ETHERNET 1
-#define WIFI 2
-#define MESH_LOWPAN_ND 3
-#define MESH_THREAD 4
-#define ATMEL 5
-#define MCR20 6
-
#define STRINGIFY(s) #s
-// Check if using mesh networking, define helper
-#if MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
- #define MESH
-#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
- #define MESH
-#endif
-
-#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
+// EASY_CONNECT_MESH coming via easy-connect
+#if defined (EASY_CONNECT_MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
// Mesh is always IPV6 - also WiFi and ETH can be IPV6 if IPV6 is enabled
M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv6;
#else
@@ -54,7 +41,7 @@
#endif
//Select binding mode: UDP or TCP -- note - Mesh networking is IPv6 UDP ONLY
-#ifdef MESH
+#if defined (EASY_CONNECT_MESH)
M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP;
#else
// WiFi or Ethernet supports both - TCP by default to avoid
--- a/zxing_main.cpp Mon Apr 17 05:28:29 2017 +0000
+++ b/zxing_main.cpp Thu Dec 13 08:28:47 2018 +0000
@@ -1,143 +1,162 @@
#include "mbed.h"
-#include "rtos.h"
-#include "DisplayBace.h"
+#include "EasyAttach_CameraAndLCD.h"
#include "ImageReaderSource.h"
-
-#define VIDEO_CVBS (0) /* Analog Video Signal */
-#define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */
+#include "AsciiFont.h"
/**** User Selection *********/
-/** Camera setting **/
-#define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */
-#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) */
-#define LCD_TYPE (0) /* Select 0(4.3inch) or 1(7.1inch) */
/** JPEG out setting **/
-#define JPEG_SEND (0) /* Select 0(JPEG images are not output to PC) or 1(JPEG images are output to PC on USB(CDC) for focusing the camera) */
+#define JPEG_SEND (1) /* Select 0(JPEG images are not output to PC) or 1(JPEG images are output to PC on USB(CDC) for focusing the camera) */
+#define JPEG_ENCODE_QUALITY (75) /* JPEG encode quality (min:1, max:75 (Considering the size of JpegBuffer, about 75 is the upper limit.)) */
+#define VFIELD_INT_SKIP_CNT (0) /* A guide for GR-LYCHEE. 0:60fps, 1:30fps, 2:20fps, 3:15fps, 4:12fps, 5:10fps */
/** Decode hints **/
#define DECODE_HINTS (DecodeHints::ONED_HINT | DecodeHints::QR_CODE_HINT | DecodeHints::DATA_MATRIX_HINT | DecodeHints::AZTEC_HINT)
/*****************************/
-#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
- #include "AsciiFont.h"
-#endif
-
-#if JPEG_SEND
- #include "JPEG_Converter.h"
- #include "DisplayApp.h"
-#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 */
+/* Video input and LCD layer 0 output */
#define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_YCBCR422)
#define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_YCBCR422)
+//#define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
#define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_16BIT)
-#define FRAME_BUFFER_BYTE_PER_PIXEL (2u)
-
-#if VIDEO_INPUT_METHOD == VIDEO_CVBS
- #define WAIT_VFIELD_CNT (2)
-#else
- #define WAIT_VFIELD_CNT (1)
-#endif
-
-/* The size of the video input */
-#if ((LCD_ONOFF) && (LCD_TYPE == 0))
- #define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH
- #define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT
-#else
- #define VIDEO_PIXEL_HW (640) /* VGA */
- #define VIDEO_PIXEL_VW (480) /* VGA */
-#endif
+#define DATA_SIZE_PER_PIC (2u)
/*! 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_STRIDE (((VIDEO_PIXEL_HW * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
+#if MBED_CONF_APP_LCD
+ #define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH /* QVGA */
+ #define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT /* QVGA */
+#else
+ #define VIDEO_PIXEL_HW (640u) /* VGA */
+ #define VIDEO_PIXEL_VW (480u) /* VGA */
+#endif
-static DisplayBase Display;
+#define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
+#define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
+
+DisplayBase Display;
+// Timer
static Timer decode_timer;
-/* 32 bytes aligned */
-static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW]__attribute((section("NC_BSS"),aligned(32)));
+#if defined(__ICCARM__)
+#pragma data_alignment=32
+static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]@ ".mirrorram";
+#else
+static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
+#endif
+
+#if JPEG_SEND
+#include "JPEG_Converter.h"
+#include "DisplayApp.h"
+#include "dcache-control.h"
-static volatile int32_t vfield_count = 0;
-static bool graphics_init_end = false;
+#if defined(__ICCARM__)
+#pragma data_alignment=32
+static uint8_t JpegBuffer[2][1024 * 64];
+#else
+static uint8_t JpegBuffer[2][1024 * 64]__attribute((aligned(32)));
+#endif
+static size_t jcu_encode_size[2];
+static JPEG_Converter Jcu;
+static int jcu_buf_index_write = 0;
+static int jcu_buf_index_write_done = 0;
+static int jcu_buf_index_read = 0;
+static volatile int jcu_encoding = 0;
+static volatile int image_change = 0;
+static DisplayApp display_app;
+static int Vfield_Int_Cnt = 0;
+
static int decode_wait_time = 0;
static void (*p_callback_func)(char * addr, int size);
-#if LCD_ONOFF
-/****** LCD ******/
-static DigitalOut lcd_pwon(P7_15);
-static DigitalOut lcd_blon(P8_1);
-static PwmOut lcd_cntrst(P8_15);
-
-static void Init_LCD_Display(void) {
- DisplayBase::graphics_error_t error;
- DisplayBase::lcd_config_t lcd_config;
- PinName lvds_pin[8] = {
- /* data pin */
- P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
- };
+static void JcuEncodeCallBackFunc(JPEG_Converter::jpeg_conv_error_t err_code) {
+ if (err_code == JPEG_Converter::JPEG_CONV_OK) {
+ jcu_buf_index_write_done = jcu_buf_index_write;
+ image_change = 1;
+ }
+ jcu_encoding = 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();
+static void snapshot(void) {
+ while ((jcu_encoding == 1) || (image_change == 0)) {
+ Thread::wait(1);
}
- graphics_init_end = true;
+ jcu_buf_index_read = jcu_buf_index_write_done;
+ image_change = 0;
+ display_app.SendJpeg(JpegBuffer[jcu_buf_index_read], (int)jcu_encode_size[jcu_buf_index_read]);
}
-static void Start_LCD_Display(uint8_t * p_buf) {
+static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
+ if (Vfield_Int_Cnt < VFIELD_INT_SKIP_CNT) {
+ Vfield_Int_Cnt++;
+ return;
+ }
+ Vfield_Int_Cnt = 0;
+
+ //Interrupt callback function
+ if (jcu_encoding == 0) {
+ JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
+ JPEG_Converter::encode_options_t encode_options;
+
+ bitmap_buff_info.width = VIDEO_PIXEL_HW;
+ bitmap_buff_info.height = VIDEO_PIXEL_VW;
+ bitmap_buff_info.format = JPEG_Converter::WR_RD_YCbCr422;
+ bitmap_buff_info.buffer_address = (void *)user_frame_buffer0;
+
+ encode_options.encode_buff_size = sizeof(JpegBuffer[0]);
+ encode_options.p_EncodeCallBackFunc = &JcuEncodeCallBackFunc;
+// encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_32_16_8BIT;
+ encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_16_8BIT;
+
+ jcu_encoding = 1;
+ if (jcu_buf_index_read == jcu_buf_index_write) {
+ jcu_buf_index_write ^= 1; // toggle
+ }
+ jcu_encode_size[jcu_buf_index_write] = 0;
+ dcache_invalid(JpegBuffer[jcu_buf_index_write], sizeof(JpegBuffer[0]));
+ if (Jcu.encode(&bitmap_buff_info, JpegBuffer[jcu_buf_index_write],
+ &jcu_encode_size[jcu_buf_index_write], &encode_options) != JPEG_Converter::JPEG_CONV_OK) {
+ jcu_encode_size[jcu_buf_index_write] = 0;
+ jcu_encoding = 0;
+ }
+ }
+}
+#endif
+
+static void Start_Video_Camera(void) {
+ // Video capture setting (progressive form fixed)
+ Display.Video_Write_Setting(
+ DisplayBase::VIDEO_INPUT_CHANNEL_0,
+ DisplayBase::COL_SYS_NTSC_358,
+ (void *)user_frame_buffer0,
+ FRAME_BUFFER_STRIDE,
+ VIDEO_FORMAT,
+ WR_RD_WRSWA,
+ VIDEO_PIXEL_VW,
+ VIDEO_PIXEL_HW
+ );
+ EasyAttach_CameraStart(Display, DisplayBase::VIDEO_INPUT_CHANNEL_0);
+}
+
+#if MBED_CONF_APP_LCD
+static void Start_LCD_Display(void) {
DisplayBase::rect_t rect;
rect.vs = 0;
- rect.vw = VIDEO_PIXEL_VW;
+ rect.vw = LCD_PIXEL_HEIGHT;
rect.hs = 0;
- rect.hw = VIDEO_PIXEL_HW;
+ rect.hw = LCD_PIXEL_WIDTH;
Display.Graphics_Read_Setting(
DisplayBase::GRAPHICS_LAYER_0,
- (void *)p_buf,
+ (void *)user_frame_buffer0,
FRAME_BUFFER_STRIDE,
GRAPHICS_FORMAT,
WR_RD_WRSWA,
&rect
);
Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
+
+ Thread::wait(50);
+ EasyAttach_LcdBacklight(true);
}
#define VIDEO_PIXEL_HW_STR (VIDEO_PIXEL_HW - 64)
@@ -148,6 +167,7 @@
static uint8_t user_frame_buffer_string[FRAME_BUFFER_STRIDE_STR * VIDEO_PIXEL_VW_STR]__attribute((section("NC_BSS"),aligned(32)));
static AsciiFont ascii_font(user_frame_buffer_string, VIDEO_PIXEL_HW_STR, VIDEO_PIXEL_VW_STR, FRAME_BUFFER_STRIDE_STR, FRAME_BUFFER_BYTE_PER_PIXEL_STR);
static bool string_draw;
+static int error_cnt;
static void decode_string_init(void) {
DisplayBase::rect_t rect;
@@ -159,15 +179,16 @@
rect.hs = 32;
rect.hw = VIDEO_PIXEL_HW_STR;
Display.Graphics_Read_Setting(
- DisplayBase::GRAPHICS_LAYER_1,
+ DisplayBase::GRAPHICS_LAYER_2,
(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);
+ Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
string_draw = false;
+ error_cnt = 0;
}
static void decode_string_disp(char ** decode_str) {
@@ -189,235 +210,45 @@
draw_line++;
}
string_draw = true;
+ error_cnt = 0;
} else {
if (string_draw != false) {
- /* Clear string */
- ascii_font.Erase(0x00000000); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
- string_draw = false;
+ error_cnt++;
+ if (error_cnt > 15) {
+ /* Clear string */
+ ascii_font.Erase(0x00000000); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
+ string_draw = false;
+ }
}
}
}
-#endif // LCD_ONOFF
-
-#if JPEG_SEND
-/****** Jpeg Send ******/
-#define JPEG_ENC_MAX_SIZE (1024 * 63)
-#define JPEG_SIGNAL_CAP_COMP (1L)
-
-#define JPEGSEND_STB (0)
-#define JPEGSEND_ENC (1)
-
-static Thread jpegsendTask(osPriorityAboveNormal, 2048);
-static DisplayApp display_app;
-static uint8_t JpegBuffer[JPEG_ENC_MAX_SIZE]__attribute((section("NC_BSS"),aligned(8))); //8 bytes aligned!;
-volatile static uint32_t jpegsend_status = JPEGSEND_STB;
-
-static void jpegsendTask_main( void ) {
- JPEG_Converter Jcu;
- size_t jcu_encode_size;
-
- while (1) {
- Thread::signal_wait(JPEG_SIGNAL_CAP_COMP, 80);
- jpegsend_status = JPEGSEND_ENC;
-
- /* JPEG Enc Start */
- JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
- JPEG_Converter::encode_options_t encode_options;
- bitmap_buff_info.width = VIDEO_PIXEL_HW;
- bitmap_buff_info.height = VIDEO_PIXEL_VW;
- bitmap_buff_info.format = JPEG_Converter::WR_RD_YCbCr422;
- bitmap_buff_info.buffer_address = (void *)user_frame_buffer0;
- encode_options.encode_buff_size = sizeof(JpegBuffer);
- encode_options.p_EncodeCallBackFunc = NULL;
- encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_16_8BIT;
- jcu_encode_size = 0;
- if (Jcu.encode(&bitmap_buff_info, JpegBuffer, &jcu_encode_size, &encode_options) != JPEG_Converter::JPEG_CONV_OK) {
- jcu_encode_size = 0;
- }
-
- /* JPEG Data Send */
- if ((jcu_encode_size > 256) && (jcu_encode_size < JPEG_ENC_MAX_SIZE)) {
- display_app.SendJpeg(JpegBuffer, jcu_encode_size);
- }
- jpegsend_status = JPEGSEND_STB;
- }
-}
-
-static void jpegsendTask_init( void ) {
- jpegsendTask.start(jpegsendTask_main);
-}
-
-static void jpegsend_cap_comp( void ) {
- if (jpegsend_status == JPEGSEND_STB) {
- jpegsendTask.signal_set(JPEG_SIGNAL_CAP_COMP);
- }
-}
-#endif // JPEG_SEND
-
-/****** Video ******/
-static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
- /* Interrupt callback function for Vfield interruption */
- if (vfield_count > 0) {
- vfield_count--;
- }
-#if JPEG_SEND
- jpegsend_cap_comp();
-#endif // JPEG_SEND
-}
-
-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 JPEG_SEND
- jpegsendTask_init();
-#endif // JPEG_SEND
-#if LCD_ONOFF
- /* Initialization of LCD */
- Init_LCD_Display(); /* When using LCD, please call before than Init_Video(). */
-#endif // LCD_ONOFF
- /* Initialization of Video */
- Init_Video();
+ // Initialize the background to black
+ for (int i = 0; i < (int)sizeof(user_frame_buffer0); i += 2) {
+ user_frame_buffer0[i + 0] = 0x10;
+ user_frame_buffer0[i + 1] = 0x80;
+ }
- /* Initialization memory */
- memset(user_frame_buffer0, 0, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW));
+#if MBED_CONF_APP_LCD
+ EasyAttach_Init(Display, 640, 360);
+#else
+ EasyAttach_Init(Display);
+#endif
+#if JPEG_SEND
+ Jcu.SetQuality(JPEG_ENCODE_QUALITY);
+ // Interrupt callback function setting (Field end signal for recording function in scaler 0)
+ Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
+#endif
+ Start_Video_Camera();
+#if MBED_CONF_APP_LCD
+ decode_string_init();
+ Start_LCD_Display();
+#endif
- /* Start of Video */
- Start_Video(user_frame_buffer0);
- /* Wait for first video drawing */
- Wait_Vfield(WAIT_VFIELD_CNT);
-#if LCD_ONOFF
- decode_string_init();
- /* Start of LCD */
- Start_LCD_Display(user_frame_buffer0);
- /* Backlight on */
- Thread::wait(200);
- lcd_cntrst.write(1.0);
-#endif // LCD_ONOFF
p_callback_func = pfunc;
decode_timer.reset();
decode_timer.start();
@@ -429,7 +260,6 @@
vector<Ref<Result> > results;
char ** decode_str = NULL;
- Wait_Vfield(WAIT_VFIELD_CNT);
/* Decode barcode image */
if (decode_timer.read_ms() >= decode_wait_time) {
decode_timer.reset();
@@ -446,9 +276,9 @@
} else {
decode_wait_time = 10;
}
-#if LCD_ONOFF
+#if MBED_CONF_APP_LCD
decode_string_disp(decode_str);
-#endif // LCD_ONOFF
+#endif
}
return decode_result;
