Sample program showing how to connect GR-PEACH into Watson IoT through mbed Connector and Watson's Connector Bridge
Dependencies: AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice
Overview
This sample program shows how to connect GR-PEACH into Watson IoT through mbed Connector and Watson's Connector Bridge. Note that this program is derived from https://github.com/ARMmbed/mbed-ethernet-sample-techcon2016.
In this program, at first, the barcode data input from camera is decoded on GR-PEACH using ZXing which is an open-source, multi-format 1D/2D barcode image processing library. Then, the decoded string is sent to Watson IoT via mbed Device Connector and Watson's Connector Bridge. At last, the delivered string is confirmed via NodeRED flow.
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 )
- BP3595 ( https://developer.mbed.org/components/BP3595-for-GR-PEACH/ )
- Ethernet cable and connection to the internet
Application setup
- Select the connection type. For details, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/mbed-os_Watson-IoT_ZXing_sample/wiki/Connection-type. - Set the client credentials. For details, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/mbed-os_Watson-IoT_ZXing_sample/wiki/Client-credentials. - Change Ethernet settings. For details, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/mbed-os_Watson-IoT_ZXing_sample/wiki/Ethernet-settings. - Change Wifi settings. For details, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/mbed-os_Watson-IoT_ZXing_sample/wiki/Wifi-settings.
Building this sample program
- Import this sample program onto mbed Compiler.
- Configure this sample program in accordance with Application setup.
- Compile the example on mbed Compiler and download the resultant binary file.
- Plug the Ethernet cable into GR-PEACH if you are using Ethernet mode.
- Plug the micro-USB cable into the OpenSDA port with lies on the next to the RESET button.
- Copy the binary previously downloaded to your PC to GR-PEACH to flash this sample program. When the copy is successfully completed, the board is ready to work.
- Press the RESET button on the board to run this sample program.
- For verification, please refer to the following wiki:
https://developer.mbed.org/teams/Renesas/code/mbed-os_Watson-IoT_ZXing_sample/wiki/Monitoring-the-application.
Application resources
This sample program exposes two resources listed below:
- /311/0/5850 : Trigger to toggle LED on GR-PEACH (PUT). When "1" is sent to this resource by PUT method, LED should be turned off. Otherwise, LED should be turned on.
- /888/0/7700: Decode result of barcode data input from camera (GET)
Setup of Watson IoT
- You should create Watson IoT Instance by the following procedure:
- Login IBM Bluemix from https://console.ng.bluemix.net/ and login it.
- Select Services as follows:
- Select Internet of Things" as follows:
- Press Get Started as follows:
- Configure Watson IoT Instance
- Leave unbound
- Select the Free plan, then click Create
- You should create Watson IoT Application Credentials
Once you successfully create Watson IoT Instance, you should see the following Watson IoT dashboard:
- On dashboard, launch the Connect your devices dashboard
- Click APPS
- Click Generate API Key
- Record the API Key and Authenticatoin Token. Then click Generate after adding a comment Note that these two values will be needed in the later step.
- Watson IoT NodeRED Application should be created in accordance with the following procedure:
- Go back to your Bluemix Dashboard: https://console.ng.bluemix.net
- Click Create Application
- Select Node-RED Starter
- Enter a unique App name and Click Create
- Application will Stage after a few minutes
- Application will report app is running when the staging has completed
- Watson NodeRED Application should be binded to Watson IoT instance
- You can now see the dashboard below:
- Click Connections. Then, press Connect Existing
- Click on Watson IoT Instance badge. Then, press Connect
- NodeRED application will restage. This will take a while. Please wait for Your app is running state
- You should acquire mbed Device Connector DOMAIN value
- Go to the mbed Device Connector Dashboard: https://connector.mbed.com and log in
- Select Access Key in order to create a new token
- Click CREATE NEW ACCESS KEY and enter a unique name. Then, push ADD bution
- an API token is generated. Need to save the generated string for later steps
- You should configure Watson IoT ARM mbed Connector Bridge
- Go back to the Watson IoT Dashboard and select Extensions
- Press Add Extension
- Add ARM mbed Connector
- Setup the bridge
- Enter your Connector API Token to Access Key and MBED_DOMAIN to Domain Id, respectively. Then, click Check Connection
- If the connection is successfully established, you can see Connection Established. Then, press Done
- NodeRED Flow Example should be imported
- Open NODEFLOW_GR-PEACH.txt
- Navigate to the URL that you recorded earlier for your Watson IoT NodeRED Application (i.e. http://<app name>.mybluemix.net) and Select Go to your NodeRED flow editor
- Select menu, Import and Clipboard
- Paste the entire contents of JSON code described in NODEFLOW_GR-PEACH.txt and click Import
- Watson IoT Application Node Flow should be configured
- Double-click input node and link them to your Watson IoT instance.
- Click on the edit button
- First enter arbitrary name. Then, Watson API Key and Watson Auth Token previously acquired. Finally, press Add to save
- Enter MBED_ENDPOINT_NAME in security.h as Device ID. Then, press Done to save
- Double-click output node
- Edit API Key and Device Id in the same manner as that for input node
- Click LED OFF and LED ON node and replace MBED_ENDPOINT_NAME_GOES_HERE with MBED_ENDPOINT_NAME as shown below:
- Click Deproy to deploy NodeRED application
- Invoke sample program
- Press the reset button on GR-PEACH
- The decode result of barcode data should be shown in debug window
- Also, you can toggle LED by clicking Turn LED OFF and Turn LED ON injection node
mbedtls_mbed_client_config.h@0:ad834d403a8c, 2016-11-24 (annotated)
- Committer:
- Osamu Nakamura
- Date:
- Thu Nov 24 13:59:16 2016 +0900
- Revision:
- 0:ad834d403a8c
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Osamu Nakamura |
0:ad834d403a8c | 1 | /* |
Osamu Nakamura |
0:ad834d403a8c | 2 | * Minimal configuration for using mbedtls as part of mbed-client |
Osamu Nakamura |
0:ad834d403a8c | 3 | * |
Osamu Nakamura |
0:ad834d403a8c | 4 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved |
Osamu Nakamura |
0:ad834d403a8c | 5 | * SPDX-License-Identifier: Apache-2.0 |
Osamu Nakamura |
0:ad834d403a8c | 6 | * |
Osamu Nakamura |
0:ad834d403a8c | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Osamu Nakamura |
0:ad834d403a8c | 8 | * not use this file except in compliance with the License. |
Osamu Nakamura |
0:ad834d403a8c | 9 | * You may obtain a copy of the License at |
Osamu Nakamura |
0:ad834d403a8c | 10 | * |
Osamu Nakamura |
0:ad834d403a8c | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Osamu Nakamura |
0:ad834d403a8c | 12 | * |
Osamu Nakamura |
0:ad834d403a8c | 13 | * Unless required by applicable law or agreed to in writing, software |
Osamu Nakamura |
0:ad834d403a8c | 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Osamu Nakamura |
0:ad834d403a8c | 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Osamu Nakamura |
0:ad834d403a8c | 16 | * See the License for the specific language governing permissions and |
Osamu Nakamura |
0:ad834d403a8c | 17 | * limitations under the License. |
Osamu Nakamura |
0:ad834d403a8c | 18 | * |
Osamu Nakamura |
0:ad834d403a8c | 19 | * This file is part of mbed TLS (https://tls.mbed.org) |
Osamu Nakamura |
0:ad834d403a8c | 20 | */ |
Osamu Nakamura |
0:ad834d403a8c | 21 | |
Osamu Nakamura |
0:ad834d403a8c | 22 | |
Osamu Nakamura |
0:ad834d403a8c | 23 | #ifndef MBEDTLS_CUSTOM_CONFIG_H |
Osamu Nakamura |
0:ad834d403a8c | 24 | #define MBEDTLS_CUSTOM_CONFIG_H |
Osamu Nakamura |
0:ad834d403a8c | 25 | |
Osamu Nakamura |
0:ad834d403a8c | 26 | /* System support */ |
Osamu Nakamura |
0:ad834d403a8c | 27 | #define MBEDTLS_HAVE_ASM |
Osamu Nakamura |
0:ad834d403a8c | 28 | |
Osamu Nakamura |
0:ad834d403a8c | 29 | /* mbed TLS feature support */ |
Osamu Nakamura |
0:ad834d403a8c | 30 | #define MBEDTLS_ECP_DP_SECP256R1_ENABLED |
Osamu Nakamura |
0:ad834d403a8c | 31 | #define MBEDTLS_ECP_NIST_OPTIM |
Osamu Nakamura |
0:ad834d403a8c | 32 | #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
Osamu Nakamura |
0:ad834d403a8c | 33 | #define MBEDTLS_SSL_PROTO_TLS1_2 |
Osamu Nakamura |
0:ad834d403a8c | 34 | #define MBEDTLS_SSL_PROTO_DTLS |
Osamu Nakamura |
0:ad834d403a8c | 35 | #define MBEDTLS_SSL_DTLS_ANTI_REPLAY |
Osamu Nakamura |
0:ad834d403a8c | 36 | #define MBEDTLS_SSL_DTLS_HELLO_VERIFY |
Osamu Nakamura |
0:ad834d403a8c | 37 | #define MBEDTLS_SSL_EXPORT_KEYS |
Osamu Nakamura |
0:ad834d403a8c | 38 | |
Osamu Nakamura |
0:ad834d403a8c | 39 | /* mbed TLS modules */ |
Osamu Nakamura |
0:ad834d403a8c | 40 | #define MBEDTLS_AES_C |
Osamu Nakamura |
0:ad834d403a8c | 41 | #define MBEDTLS_ASN1_PARSE_C |
Osamu Nakamura |
0:ad834d403a8c | 42 | #define MBEDTLS_ASN1_WRITE_C |
Osamu Nakamura |
0:ad834d403a8c | 43 | #define MBEDTLS_BIGNUM_C |
Osamu Nakamura |
0:ad834d403a8c | 44 | #define MBEDTLS_CCM_C |
Osamu Nakamura |
0:ad834d403a8c | 45 | #define MBEDTLS_CIPHER_C |
Osamu Nakamura |
0:ad834d403a8c | 46 | #define MBEDTLS_CTR_DRBG_C |
Osamu Nakamura |
0:ad834d403a8c | 47 | #define MBEDTLS_ECP_C |
Osamu Nakamura |
0:ad834d403a8c | 48 | #define MBEDTLS_ENTROPY_C |
Osamu Nakamura |
0:ad834d403a8c | 49 | #define MBEDTLS_MD_C |
Osamu Nakamura |
0:ad834d403a8c | 50 | #define MBEDTLS_OID_C |
Osamu Nakamura |
0:ad834d403a8c | 51 | #define MBEDTLS_PK_C |
Osamu Nakamura |
0:ad834d403a8c | 52 | #define MBEDTLS_PK_PARSE_C |
Osamu Nakamura |
0:ad834d403a8c | 53 | #define MBEDTLS_SHA256_C |
Osamu Nakamura |
0:ad834d403a8c | 54 | #define MBEDTLS_SSL_COOKIE_C |
Osamu Nakamura |
0:ad834d403a8c | 55 | #define MBEDTLS_SSL_CLI_C |
Osamu Nakamura |
0:ad834d403a8c | 56 | #define MBEDTLS_SSL_SRV_C |
Osamu Nakamura |
0:ad834d403a8c | 57 | #define MBEDTLS_SSL_TLS_C |
Osamu Nakamura |
0:ad834d403a8c | 58 | |
Osamu Nakamura |
0:ad834d403a8c | 59 | // XXX mbedclient needs these: mbedtls_x509_crt_free, mbedtls_x509_crt_init, mbedtls_x509_crt_parse |
Osamu Nakamura |
0:ad834d403a8c | 60 | #define MBEDTLS_X509_USE_C |
Osamu Nakamura |
0:ad834d403a8c | 61 | #define MBEDTLS_X509_CRT_PARSE_C |
Osamu Nakamura |
0:ad834d403a8c | 62 | // a bit wrong way to get mbedtls_ssl_conf_psk: |
Osamu Nakamura |
0:ad834d403a8c | 63 | // XXX: this should be ifdef'd out from client too |
Osamu Nakamura |
0:ad834d403a8c | 64 | #define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED |
Osamu Nakamura |
0:ad834d403a8c | 65 | |
Osamu Nakamura |
0:ad834d403a8c | 66 | // XXX: clean these up!! |
Osamu Nakamura |
0:ad834d403a8c | 67 | #define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED |
Osamu Nakamura |
0:ad834d403a8c | 68 | #define MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED |
Osamu Nakamura |
0:ad834d403a8c | 69 | #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
Osamu Nakamura |
0:ad834d403a8c | 70 | #define MBEDTLS_SHA512_C |
Osamu Nakamura |
0:ad834d403a8c | 71 | #define MBEDTLS_ECDH_C |
Osamu Nakamura |
0:ad834d403a8c | 72 | #define MBEDTLS_GCM_C |
Osamu Nakamura |
0:ad834d403a8c | 73 | #define MBEDTLS_CCM_C |
Osamu Nakamura |
0:ad834d403a8c | 74 | |
Osamu Nakamura |
0:ad834d403a8c | 75 | #define MBEDTLS_PKCS1_V15 |
Osamu Nakamura |
0:ad834d403a8c | 76 | |
Osamu Nakamura |
0:ad834d403a8c | 77 | #define MBEDTLS_CIPHER_MODE_CBC |
Osamu Nakamura |
0:ad834d403a8c | 78 | #define MBEDTLS_ECDH_C |
Osamu Nakamura |
0:ad834d403a8c | 79 | #define MBEDTLS_ECDSA_C |
Osamu Nakamura |
0:ad834d403a8c | 80 | #define MBEDTLS_X509_CRT_PARSE_C |
Osamu Nakamura |
0:ad834d403a8c | 81 | |
Osamu Nakamura |
0:ad834d403a8c | 82 | // Remove RSA, save 20KB at total |
Osamu Nakamura |
0:ad834d403a8c | 83 | #undef MBEDTLS_RSA_C |
Osamu Nakamura |
0:ad834d403a8c | 84 | #undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
Osamu Nakamura |
0:ad834d403a8c | 85 | |
Osamu Nakamura |
0:ad834d403a8c | 86 | // Remove error messages, save 10KB of ROM |
Osamu Nakamura |
0:ad834d403a8c | 87 | #undef MBEDTLS_ERROR_C |
Osamu Nakamura |
0:ad834d403a8c | 88 | |
Osamu Nakamura |
0:ad834d403a8c | 89 | // Remove selftesting and save 11KB of ROM |
Osamu Nakamura |
0:ad834d403a8c | 90 | #undef MBEDTLS_SELF_TEST |
Osamu Nakamura |
0:ad834d403a8c | 91 | |
Osamu Nakamura |
0:ad834d403a8c | 92 | #undef MBEDTLS_SSL_COOKIE_C |
Osamu Nakamura |
0:ad834d403a8c | 93 | |
Osamu Nakamura |
0:ad834d403a8c | 94 | // Reduces ROM size by 30 kB |
Osamu Nakamura |
0:ad834d403a8c | 95 | #undef MBEDTLS_ERROR_STRERROR_DUMMY |
Osamu Nakamura |
0:ad834d403a8c | 96 | #undef MBEDTLS_VERSION_FEATURES |
Osamu Nakamura |
0:ad834d403a8c | 97 | #undef MBEDTLS_DEBUG_C |
Osamu Nakamura |
0:ad834d403a8c | 98 | |
Osamu Nakamura |
0:ad834d403a8c | 99 | // needed for parsing the certificates |
Osamu Nakamura |
0:ad834d403a8c | 100 | #define MBEDTLS_PEM_PARSE_C |
Osamu Nakamura |
0:ad834d403a8c | 101 | // dep of the previous |
Osamu Nakamura |
0:ad834d403a8c | 102 | #define MBEDTLS_BASE64_C |
Osamu Nakamura |
0:ad834d403a8c | 103 | |
Osamu Nakamura |
0:ad834d403a8c | 104 | // reduce IO buffer to save RAM, default is 16KB |
Osamu Nakamura |
0:ad834d403a8c | 105 | #define MBEDTLS_SSL_MAX_CONTENT_LEN 2048 |
Osamu Nakamura |
0:ad834d403a8c | 106 | |
Osamu Nakamura |
0:ad834d403a8c | 107 | // define to save 8KB RAM at the expense of ROM |
Osamu Nakamura |
0:ad834d403a8c | 108 | #undef MBEDTLS_AES_ROM_TABLES |
Osamu Nakamura |
0:ad834d403a8c | 109 | |
Osamu Nakamura |
0:ad834d403a8c | 110 | // Save ROM and a few bytes of RAM by specifying our own ciphersuite list |
Osamu Nakamura |
0:ad834d403a8c | 111 | #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 |
Osamu Nakamura |
0:ad834d403a8c | 112 | |
Osamu Nakamura |
0:ad834d403a8c | 113 | #include "mbedtls/check_config.h" |
Osamu Nakamura |
0:ad834d403a8c | 114 | |
Osamu Nakamura |
0:ad834d403a8c | 115 | #endif /* MBEDTLS_CUSTOM_CONFIG_H */ |