Mbed Client sample for GR-LYCHEE where ZXing is incorporated.
Dependencies: DisplayApp AsciiFont
Fork of GR-PEACH_mbed-os-client-ZXingSample by
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-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/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Connection-type. - 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. - 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:
- 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 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-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://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:
- 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 green, yellow, orange and red is acceptable (PUT).
Revision 18:0ab91e767950, committed 2018-12-13
- Comitter:
- 1050186
- Date:
- Thu Dec 13 03:31:49 2018 +0000
- Parent:
- 17:548cfbfba6d8
- Child:
- 19:03e8d4d608f0
- Commit message:
- Replace easy-connect.
Changed in this revision
--- a/easy-connect-gr-lychee.lib Tue Dec 11 09:33:39 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/users/1050186/code/easy-connect-gr-lychee/#e89012203ffa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/easy-connect/easy-connect.h Thu Dec 13 03:31:49 2018 +0000
@@ -0,0 +1,111 @@
+#ifndef __MAGIC_CONNECT_H__
+#define __MAGIC_CONNECT_H__
+
+#include "mbed.h"
+
+#define ETHERNET 1
+#define WIFI_ESP8266 2
+#define WIFI_BP3595 3
+#define WIFI_ESP32 4
+
+#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ESP8266
+#include "ESP8266Interface.h"
+
+#ifdef MBED_CONF_APP_ESP8266_DEBUG
+ESP8266Interface wifi(MBED_CONF_APP_ESP8266_TX, MBED_CONF_APP_ESP8266_RX, MBED_CONF_APP_ESP8266_DEBUG);
+#else
+ESP8266Interface wifi(MBED_CONF_APP_ESP8266_TX, MBED_CONF_APP_ESP8266_RX);
+#endif
+
+#elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_BP3595
+#include "LWIPBP3595Interface.h"
+LWIPBP3595Interface wifi;
+#elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ESP32
+#include "ESP32Interface.h"
+ESP32Interface wifi(MBED_CONF_EASY_CONNECT_WIFI_ESP32_EN, MBED_CONF_EASY_CONNECT_WIFI_ESP32_IO0, MBED_CONF_EASY_CONNECT_WIFI_ESP32_TX, MBED_CONF_EASY_CONNECT_WIFI_ESP32_RX);
+#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
+#include "EthernetInterface.h"
+EthernetInterface eth;
+#else
+#error "No connectivity method chosen. Please add 'config.network-interfaces.value' to your mbed_app.json (see README.md for more information)."
+#endif
+
+// This is address to mbed Device Connector
+#define MBED_SERVER_ADDRESS "coap://api.connector.mbed.com:5684"
+
+#ifdef MBED_CONF_APP_ESP8266_SSID
+#define MBED_CONF_APP_WIFI_SSID MBED_CONF_APP_ESP8266_SSID
+#endif
+
+#ifdef MBED_CONF_APP_ESP8266_PASSWORD
+#define MBED_CONF_APP_WIFI_PASSWORD MBED_CONF_APP_ESP8266_PASSWORD
+#endif
+
+#ifndef MBED_CONF_APP_WIFI_SECURITY
+#define MBED_CONF_APP_WIFI_SECURITY NSAPI_SECURITY_WPA_WPA2
+#endif
+
+NetworkInterface* easy_connect(bool log_messages = false) {
+ NetworkInterface* network_interface = 0;
+ int connect_success = -1;
+#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ESP8266
+ if (log_messages) {
+ printf("[EasyConnect] Using WiFi (ESP8266) \n");
+ printf("[EasyConnect] Connecting to WiFi %s\n", MBED_CONF_APP_WIFI_SSID);
+ }
+ connect_success = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, MBED_CONF_APP_WIFI_SECURITY);
+ network_interface = &wifi;
+#elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_BP3595
+ if (log_messages) {
+ printf("[EasyConnect] Using WiFi (BP3595) \n");
+ printf("[EasyConnect] Connecting to WiFi %s\n", MBED_CONF_APP_WIFI_SSID);
+ }
+ connect_success = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, MBED_CONF_APP_WIFI_SECURITY);
+ network_interface = &wifi;
+#elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ESP32
+ if (log_messages) {
+ printf("[EasyConnect] Using WiFi (ESP32) \n");
+ printf("[EasyConnect] Connecting to WiFi %s\n", MBED_CONF_APP_WIFI_SSID);
+ }
+ connect_success = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, MBED_CONF_APP_WIFI_SECURITY);
+ network_interface = &wifi;
+#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
+ if (log_messages) {
+ printf("[EasyConnect] Using Ethernet\n");
+ }
+ connect_success = eth.connect();
+ network_interface = ð
+#endif
+ if(connect_success == 0) {
+ if (log_messages) {
+ printf("[EasyConnect] Connected to Network successfully\n");
+ }
+ } else {
+ if (log_messages) {
+ printf("[EasyConnect] Connection to Network Failed %d!\n", connect_success);
+ }
+ return NULL;
+ }
+ const char *ip_addr = network_interface->get_ip_address();
+ const char *mac_addr = network_interface->get_mac_address();
+ if (ip_addr == NULL) {
+ if (log_messages) {
+ printf("[EasyConnect] ERROR - No IP address\n");
+ }
+ return NULL;
+ }
+ if (mac_addr == NULL) {
+ if (log_messages) {
+ printf("[EasyConnect] ERROR - No MAC address\n");
+ }
+ return NULL;
+ }
+ if (log_messages) {
+ printf("[EasyConnect] IP address %s\n", ip_addr);
+ printf("[EasyConnect] MAC address %s\n", mac_addr);
+ }
+ return network_interface;
+}
+
+#endif // __MAGIC_CONNECT_H__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/easy-connect/mbed_lib.json Thu Dec 13 03:31:49 2018 +0000
@@ -0,0 +1,55 @@
+{
+ "name": "easy-connect",
+ "config": {
+ "wifi-esp32-en": {
+ "help": "EN pin of external device (ESP32)",
+ "value": "NC"
+ },
+ "wifi-esp32-io0": {
+ "help": "IO0 pin of external device (ESP32)",
+ "value": "NC"
+ },
+ "wifi-esp32-tx": {
+ "help": "TX pin for serial connection to external device (ESP32)",
+ "value": "D1"
+ },
+ "wifi-esp32-rx": {
+ "help": "RX pin for serial connection to external device (ESP32)",
+ "value": "D0"
+ },
+ "wifi-esp32-rts": {
+ "help": "RTS pin for serial connection to external device (ESP32)",
+ "value": "NC"
+ },
+ "wifi-esp32-cts": {
+ "help": "CTS pin for serial connection to external device (ESP32)",
+ "value": "NC"
+ },
+ "wifi-esp32-baud-rate": {
+ "help": "Baud rate for ESP32",
+ "value": 115200
+ }
+ },
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["COMMON_PAL"]
+ },
+ "RZ_A1H": {
+ "wifi-esp32-en" : "P3_10",
+ "wifi-esp32-io0": "P3_9",
+ "wifi-esp32-tx" : "P2_14",
+ "wifi-esp32-rx" : "P2_15",
+ "wifi-esp32-baud-rate" : 230400
+ },
+ "GR_LYCHEE": {
+ "wifi-esp32-en" : "P5_3",
+ "wifi-esp32-io0" : "P3_14",
+ "wifi-esp32-tx" : "P7_1",
+ "wifi-esp32-rx" : "P0_1",
+ "wifi-esp32-rts" : "P7_7",
+ "wifi-esp32-cts" : "P7_6",
+ "wifi-esp32-baud-rate" : 230400
+ }
+ }
+}
+
--- a/main.cpp Tue Dec 11 09:33:39 2018 +0000 +++ b/main.cpp Thu Dec 13 03:31:49 2018 +0000 @@ -59,11 +59,7 @@ // 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 -#ifdef TARGET_GR_LYCHEE -#include "easy-connect-gr-lychee/easy-connect.h" -#else #include "easy-connect/easy-connect.h" -#endif // Should be defined after easy-connect.h #include "simpleclient.h"
--- a/mbed_app.json Tue Dec 11 09:33:39 2018 +0000
+++ b/mbed_app.json Thu Dec 13 03:31:49 2018 +0000
@@ -2,7 +2,7 @@
"config": {
"network-interface":{
"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"
+ "value": "WIFI_ESP32"
},
"mesh_radio_type": {
"help": "options are ATMEL, MCR20, SPIRIT1, EFR32",
@@ -10,11 +10,11 @@
},
"wifi-ssid": {
"help": "WiFi SSID",
- "value": "\"SSID\""
+ "value": "\"SH-01G_AP\""
},
"wifi-password": {
"help": "WiFi Password",
- "value": "\"Password\""
+ "value": "\"97860acdd495\""
},
"wifi-security":{
"help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
--- a/security.h Tue Dec 11 09:33:39 2018 +0000 +++ b/security.h Thu Dec 13 03:31:49 2018 +0000 @@ -1,35 +1,109 @@ /* + * 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 "c044ba4e-1a9a-4593-b0b0-87f5d5b44652" + +#define MBED_ENDPOINT_NAME "8e9994d0-d238-46f1-b9cd-8d2e7fcaaa74" + -#include <inttypes.h> + +const uint8_t SERVER_CERT[] = "-----BEGIN CERTIFICATE-----\r\n" + +"MIIBqDCCAU+gAwIBAgIRAOv/vH36PyOwG5J+g5gAAAAwCgYIKoZIzj0EAwIwSzEL\r\n" + +"MAkGA1UEBhMCRkkxDTALBgNVBAcMBE91bHUxDDAKBgNVBAoMA0FSTTEMMAoGA1UE\r\n" + +"CwwDSW9UMREwDwYDVQQDDAhBUk0gbWJlZDAiGA8yMDE4MDQyMDAwMDAwMFoYDzIy\r\n" + +"MDAwMTAxMDAwMDAwWjBLMQswCQYDVQQGEwJGSTENMAsGA1UEBwwET3VsdTEMMAoG\r\n" + +"A1UECgwDQVJNMQwwCgYDVQQLDANJb1QxETAPBgNVBAMMCEFSTSBtYmVkMFkwEwYH\r\n" + +"KoZIzj0CAQYIKoZIzj0DAQcDQgAEu4DItKTSYDdrCAVHmbDZEe2Hju1FQ7jir9F3\r\n" + +"MVmcuwCx3XwSzF3ksKlxP3DS2818G/jEnEbDTBxis8MNvz+uO6MQMA4wDAYDVR0T\r\n" + +"BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiBP55WaRmAek8EBdlKHF6Q3PSwUA3lN\r\n" + +"xgJ3vjCHwfOZwAIgIZGTaizc+01uxzisdpwjLtSdNtKNI3tfITaMHLsyRjM=\r\n" + +"-----END CERTIFICATE-----\r\n"; + -#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" + +"MIIBzzCCAXOgAwIBAgIEW+TM4jAMBggqhkjOPQQDAgUAMDkxCzAJBgNVBAYTAkZ\r\n" + +"JMQwwCgYDVQQKDANBUk0xHDAaBgNVBAMME21iZWQtY29ubmVjdG9yLTIwMTgwHh\r\n" + +"cNMTgxMjEzMDMwNTI5WhcNMTgxMjMxMDYwMDAwWjCBoTFSMFAGA1UEAxNJYzA0N\r\n" + +"GJhNGUtMWE5YS00NTkzLWIwYjAtODdmNWQ1YjQ0NjUyLzhlOTk5NGQwLWQyMzgt\r\n" + +"NDZmMS1iOWNkLThkMmU3ZmNhYWE3NDEMMAoGA1UECxMDQVJNMRIwEAYDVQQKEwl\r\n" + +"tYmVkIHVzZXIxDTALBgNVBAcTBE91bHUxDTALBgNVBAgTBE91bHUxCzAJBgNVBA\r\n" + +"YTAkZJMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUefv5yVLBb6kbF3uqYNjh\r\n" + +"tENq8G4i21rfrMgLck5KH5HJeM6TArBwK0SejzTicTmbx/1KETsEmv2KW6Ch56o\r\n" + +"5TAMBggqhkjOPQQDAgUAA0gAMEUCIQCK/wtsEUiWRPj7xlYwK5OGDcirOVBts4d\r\n" + +"TMb7JwWjTIgIgYurBY4WFr34r1oCCyk+7FBZyUQl8kDxGDyLklHY9FaI=\r\n" + "-----END CERTIFICATE-----\r\n"; + + const uint8_t KEY[] = "-----BEGIN PRIVATE KEY-----\r\n" + +"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgWi3qeKOyj0BA3lLp\r\n" + +"+tZW0YHZILbMiZ2RJBWOgw8FufOhRANCAARR5+/nJUsFvqRsXe6pg2OG0Q2rwbiL\r\n" + +"bWt+syAtyTkofkcl4zpMCsHArRJ6PNOJxOZvH/UoROwSa/YpboKHnqjl\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"
