Sample program for communicating with Fujitsuu IoT Platform using HTTP

Dependencies:   AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP USBHost_custom easy-connect-gr-peach mbed-http picojson BM1383GLV KX022 rohm-sensor-hal rohm-bh1745

Overview

This sample program shows how to send the cognitive data and sensing data gathered by Omron HVC-P2 and Rohm Sensor Shield respectively to IoT Platform managed by FUJITSU ( http://jp.fujitsu.com/solutions/cloud/k5/function/paas/iot-platform/ ).

Required Hardware

Application Setup

  1. Configure the connection type. For details, please refer to the following link:
    https://developer.mbed.org/teams/Renesas/code/GR-PEACH_IoT_Platform_HTTP_sample/wiki/Connection-Type
  2. Configure Ethernet settings. For details, please refer to the following link:
    https://developer.mbed.org/teams/Renesas/code/GR-PEACH_IoT_Platform_HTTP_sample/wiki/Ethernet-settings
  3. Set up the Access Code of resource where the gathered data would be stored. For details on Access Code, please refer to the following links:
    https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/userguide_en.pdf
    https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/apireference_en.pdf
    https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/portalmanual_en.pdf
  4. Set up URI for the resource where the gathered data would be stored. For details, please refer to the following link:
    https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/userguide_en.pdf
    https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/apireference_en.pdf

Building Example

  1. Import this sample program onto mbed Compiler
  2. Configure the program in accordance with the description of Application Setup above
  3. Compile the sample program
  4. Plug the Ethernet cable into GR-PEACH if you would like Ethernet mode
  5. Plug micro-USB cable into the OpenSDA port which lies on the next to the RESET button
  6. Copy the binary previously downloaded to your PC to GR-PEACH in order to flash this program. When the copy is successfully completed, the drive named MBED should be re-mounted automatically
  7. Press the RESET button on the board to run the sample application

Data Format sent to IoT Platform

In this sample program, the cognitive data and sensing data are serialized into the following JSON format using picojson (https://developer.mbed.org/users/mimil/code/picojson/):

  • Face detection data

{
    "RecordType": "HVC-P2(face)",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "Age": xxx,
    "FaceRectangle": {
        "Height": xxx,
        "Left": xxx,
        "Top": xxx,
        "Width": xxx
    },
    "Gender": xxx,
    "Scores": {
        "Anger": xxx,
        "Happiness": xxx,
        "Neutral": xxx,
        "Sadness": xxx,
        "Surprise": xxx
    }
}
  • Body detection data

{
    "RecodeType": "HVC-P2(body)",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "BodyRectangle": {
        "Height": xxx,
        "Left": xxx,
        "Top": xxx,
        "Width": xxx
    }
}
  • Accelerometer data

{
    "RecodeType": "Accelerometer",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "data": [ acceleratoin(x-direction), acceleration(y-direction), acceleration(z-direction), null, null, null ]
}

Note that data[0], data[1] and data[2] are filled with the acceleration data in x, y and z direction respectively, and the remaining elements are filled with null.

  • Atmosphere data

{
    "RecodeType": "Atmosphere",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "data": [ atmosphere data, null, null, null, null, null ]
}

Note that data[0] is filled with atmosphere data, and the remaining elements are filled with null.

  • Color sensor data

{
    "RecodeType": "Color",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "data": [ Red, Green, Blue, Alpha, null, null]
}

Note that data[0], data[1], data[2] and data[3] are filled with Red, Green, Blue and Alpha elements of color respectively, and the remaining elements are filled with null.

  • Temperature data

{
    "RecodeType": "Temperature",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "data": [ Temperature, null, null, null, null, null ]
}

Note that data[0] is filled with temperature data, the remaining elements are filled with null.

  • Geomagnetism

{
    "RecodeType": "Geomagnetism",
    "id": "<GR-PEACH ID>-<Sensor ID>",
    "data": [ geomagnetism(x-direction), geomagnetism(y-direction), geomagnetism(z-direction), null, null, null]
}

Note that data[0], data[1] and data[2] are filled with the geomagnetism data in x, y and z direction respectively, and the remaining elements are filled with null.

Committer:
Osamu Nakamura
Date:
Thu Apr 12 19:04:23 2018 +0900
Revision:
7:9ae73f85dc04
Parent:
0:8373b6833bde
Update BM1422AGMV driver so that it can be compiled by ARMCC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Osamu Nakamura 0:8373b6833bde 1 /*---------------------------------------------------------------------------*/
Osamu Nakamura 0:8373b6833bde 2 /* Copyright(C) 2017 OMRON Corporation */
Osamu Nakamura 0:8373b6833bde 3 /* */
Osamu Nakamura 0:8373b6833bde 4 /* Licensed under the Apache License, Version 2.0 (the "License"); */
Osamu Nakamura 0:8373b6833bde 5 /* you may not use this file except in compliance with the License. */
Osamu Nakamura 0:8373b6833bde 6 /* You may obtain a copy of the License at */
Osamu Nakamura 0:8373b6833bde 7 /* */
Osamu Nakamura 0:8373b6833bde 8 /* http://www.apache.org/licenses/LICENSE-2.0 */
Osamu Nakamura 0:8373b6833bde 9 /* */
Osamu Nakamura 0:8373b6833bde 10 /* Unless required by applicable law or agreed to in writing, software */
Osamu Nakamura 0:8373b6833bde 11 /* distributed under the License is distributed on an "AS IS" BASIS, */
Osamu Nakamura 0:8373b6833bde 12 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
Osamu Nakamura 0:8373b6833bde 13 /* See the License for the specific language governing permissions and */
Osamu Nakamura 0:8373b6833bde 14 /* limitations under the License. */
Osamu Nakamura 0:8373b6833bde 15 /*---------------------------------------------------------------------------*/
Osamu Nakamura 0:8373b6833bde 16
Osamu Nakamura 0:8373b6833bde 17 /*
Osamu Nakamura 0:8373b6833bde 18 HVC Sample API
Osamu Nakamura 0:8373b6833bde 19 */
Osamu Nakamura 0:8373b6833bde 20
Osamu Nakamura 0:8373b6833bde 21 #ifndef HVCApi_H__
Osamu Nakamura 0:8373b6833bde 22 #define HVCApi_H__
Osamu Nakamura 0:8373b6833bde 23
Osamu Nakamura 0:8373b6833bde 24 #ifndef UINT8
Osamu Nakamura 0:8373b6833bde 25 typedef unsigned char UINT8; /* 8 bit Unsigned Integer */
Osamu Nakamura 0:8373b6833bde 26 #endif /* UINT8 */
Osamu Nakamura 0:8373b6833bde 27 #ifndef INT32
Osamu Nakamura 0:8373b6833bde 28 typedef int INT32; /* 32 bit Signed Integer */
Osamu Nakamura 0:8373b6833bde 29 #endif /* INT32 */
Osamu Nakamura 0:8373b6833bde 30 #ifndef NULL
Osamu Nakamura 0:8373b6833bde 31 #define NULL 0
Osamu Nakamura 0:8373b6833bde 32 #endif
Osamu Nakamura 0:8373b6833bde 33
Osamu Nakamura 0:8373b6833bde 34 #include "HVCDef.h"
Osamu Nakamura 0:8373b6833bde 35
Osamu Nakamura 0:8373b6833bde 36 #ifdef __cplusplus
Osamu Nakamura 0:8373b6833bde 37 extern "C" {
Osamu Nakamura 0:8373b6833bde 38 #endif
Osamu Nakamura 0:8373b6833bde 39
Osamu Nakamura 0:8373b6833bde 40 /* HVC_GetVersion */
Osamu Nakamura 0:8373b6833bde 41 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 42 /* : HVC_VERSION *outVersion version data */
Osamu Nakamura 0:8373b6833bde 43 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 44 INT32 HVC_GetVersion(INT32 inTimeOutTime, HVC_VERSION *outVersion, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 45
Osamu Nakamura 0:8373b6833bde 46 /* HVC_SetCameraAngle */
Osamu Nakamura 0:8373b6833bde 47 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 48 /* : INT32 inAngleNo camera angle number */
Osamu Nakamura 0:8373b6833bde 49 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 50 INT32 HVC_SetCameraAngle(INT32 inTimeOutTime, INT32 inAngleNo, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 51
Osamu Nakamura 0:8373b6833bde 52 /* HVC_GetCameraAngle */
Osamu Nakamura 0:8373b6833bde 53 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 54 /* : INT32 *outAngleNo camera angle number */
Osamu Nakamura 0:8373b6833bde 55 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 56 INT32 HVC_GetCameraAngle(INT32 inTimeOutTime, INT32 *outAngleNo, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 57
Osamu Nakamura 0:8373b6833bde 58 /* HVC_Execute */
Osamu Nakamura 0:8373b6833bde 59 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 60 /* : INT32 inExec executable function */
Osamu Nakamura 0:8373b6833bde 61 /* : INT32 inImage image output number */
Osamu Nakamura 0:8373b6833bde 62 /* : HVC_RESULT *outHVCResult result data */
Osamu Nakamura 0:8373b6833bde 63 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 64 INT32 HVC_Execute(INT32 inTimeOutTime, INT32 inExec, INT32 inImage, HVC_RESULT *outHVCResult, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 65
Osamu Nakamura 0:8373b6833bde 66 /* HVC_ExecuteEx */
Osamu Nakamura 0:8373b6833bde 67 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 68 /* : INT32 inExec executable function */
Osamu Nakamura 0:8373b6833bde 69 /* : INT32 inImage image output number */
Osamu Nakamura 0:8373b6833bde 70 /* : HVC_RESULT *outHVCResult result data */
Osamu Nakamura 0:8373b6833bde 71 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 72 INT32 HVC_ExecuteEx(INT32 inTimeOutTime, INT32 inExec, INT32 inImage, HVC_RESULT *outHVCResult, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 73
Osamu Nakamura 0:8373b6833bde 74 /* HVC_SetThreshold */
Osamu Nakamura 0:8373b6833bde 75 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 76 /* : HVC_THRESHOLD *inThreshold threshold values */
Osamu Nakamura 0:8373b6833bde 77 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 78 INT32 HVC_SetThreshold(INT32 inTimeOutTime, HVC_THRESHOLD *inThreshold, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 79
Osamu Nakamura 0:8373b6833bde 80 /* HVC_GetThreshold */
Osamu Nakamura 0:8373b6833bde 81 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 82 /* : HVC_THRESHOLD *outThreshold threshold values */
Osamu Nakamura 0:8373b6833bde 83 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 84 INT32 HVC_GetThreshold(INT32 inTimeOutTime, HVC_THRESHOLD *outThreshold, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 85
Osamu Nakamura 0:8373b6833bde 86 /* HVC_SetSizeRange */
Osamu Nakamura 0:8373b6833bde 87 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 88 /* : HVC_SIZERANGE *inSizeRange detection sizes */
Osamu Nakamura 0:8373b6833bde 89 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 90 INT32 HVC_SetSizeRange(INT32 inTimeOutTime, HVC_SIZERANGE *inSizeRange, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 91
Osamu Nakamura 0:8373b6833bde 92 /* HVC_GetSizeRange */
Osamu Nakamura 0:8373b6833bde 93 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 94 /* : HVC_SIZERANGE *outSizeRange detection sizes */
Osamu Nakamura 0:8373b6833bde 95 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 96 INT32 HVC_GetSizeRange(INT32 inTimeOutTime, HVC_SIZERANGE *outSizeRange, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 97
Osamu Nakamura 0:8373b6833bde 98 /* HVC_SetFaceDetectionAngle */
Osamu Nakamura 0:8373b6833bde 99 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 100 /* : INT32 inPose Yaw angle range */
Osamu Nakamura 0:8373b6833bde 101 /* : INT32 inAngle Roll angle range */
Osamu Nakamura 0:8373b6833bde 102 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 103 INT32 HVC_SetFaceDetectionAngle(INT32 inTimeOutTime, INT32 inPose, INT32 inAngle, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 104
Osamu Nakamura 0:8373b6833bde 105 /* HVC_GetFaceDetectionAngle */
Osamu Nakamura 0:8373b6833bde 106 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 107 /* : INT32 *outPose Yaw angle range */
Osamu Nakamura 0:8373b6833bde 108 /* : INT32 *outAngle Roll angle range */
Osamu Nakamura 0:8373b6833bde 109 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 110 INT32 HVC_GetFaceDetectionAngle(INT32 inTimeOutTime, INT32 *outPose, INT32 *outAngle, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 111
Osamu Nakamura 0:8373b6833bde 112 /* HVC_SetBaudRate */
Osamu Nakamura 0:8373b6833bde 113 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 114 /* : INT32 inRate Baudrate */
Osamu Nakamura 0:8373b6833bde 115 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 116 INT32 HVC_SetBaudRate(INT32 inTimeOutTime, INT32 inRate, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 117
Osamu Nakamura 0:8373b6833bde 118 /* HVC_Registration */
Osamu Nakamura 0:8373b6833bde 119 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 120 /* : INT32 inUserID User ID (0-499) */
Osamu Nakamura 0:8373b6833bde 121 /* : INT32 inDataID Data ID (0-9) */
Osamu Nakamura 0:8373b6833bde 122 /* : HVC_IMAGE *outImage image info */
Osamu Nakamura 0:8373b6833bde 123 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 124 INT32 HVC_Registration(INT32 inTimeOutTime, INT32 inUserID, INT32 inDataID, HVC_IMAGE *outImage, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 125
Osamu Nakamura 0:8373b6833bde 126 /* HVC_DeleteData */
Osamu Nakamura 0:8373b6833bde 127 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 128 /* : INT32 inUserID User ID (0-499) */
Osamu Nakamura 0:8373b6833bde 129 /* : INT32 inDataID Data ID (0-9) */
Osamu Nakamura 0:8373b6833bde 130 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 131 INT32 HVC_DeleteData(INT32 inTimeOutTime, INT32 inUserID, INT32 inDataID, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 132
Osamu Nakamura 0:8373b6833bde 133 /* HVC_DeleteUser */
Osamu Nakamura 0:8373b6833bde 134 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 135 /* : INT32 inUserID User ID (0-499) */
Osamu Nakamura 0:8373b6833bde 136 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 137 INT32 HVC_DeleteUser(INT32 inTimeOutTime, INT32 inUserID, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 138
Osamu Nakamura 0:8373b6833bde 139 /* HVC_DeleteAll */
Osamu Nakamura 0:8373b6833bde 140 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 141 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 142 INT32 HVC_DeleteAll(INT32 inTimeOutTime, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 143
Osamu Nakamura 0:8373b6833bde 144 /* HVC_GetUserData */
Osamu Nakamura 0:8373b6833bde 145 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 146 /* : INT32 inUserID User ID (0-499) */
Osamu Nakamura 0:8373b6833bde 147 /* : INT32 *outDataNo Registration Info */
Osamu Nakamura 0:8373b6833bde 148 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 149 INT32 HVC_GetUserData(INT32 inTimeOutTime, INT32 inUserID, INT32 *outDataNo, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 150
Osamu Nakamura 0:8373b6833bde 151 /* HVC_SaveAlbum */
Osamu Nakamura 0:8373b6833bde 152 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 153 /* : UINT8 *outAlbumData Album data */
Osamu Nakamura 0:8373b6833bde 154 /* : INT32 *outAlbumDataSize Album data size */
Osamu Nakamura 0:8373b6833bde 155 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 156 INT32 HVC_SaveAlbum(INT32 inTimeOutTime, UINT8 *outAlbumData, INT32 *outAlbumDataSize, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 157
Osamu Nakamura 0:8373b6833bde 158 /* HVC_LoadAlbum */
Osamu Nakamura 0:8373b6833bde 159 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 160 /* : UINT8 *inAlbumData Album data */
Osamu Nakamura 0:8373b6833bde 161 /* : INT32 inAlbumDataSize Album data size */
Osamu Nakamura 0:8373b6833bde 162 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 163 INT32 HVC_LoadAlbum(INT32 inTimeOutTime, UINT8 *inAlbumData, INT32 inAlbumDataSize, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 164
Osamu Nakamura 0:8373b6833bde 165 /* HVC_WriteAlbum */
Osamu Nakamura 0:8373b6833bde 166 /* param : INT32 inTimeOutTime timeout time (ms) */
Osamu Nakamura 0:8373b6833bde 167 /* : UINT8 *outStatus response code */
Osamu Nakamura 0:8373b6833bde 168 INT32 HVC_WriteAlbum(INT32 inTimeOutTime, UINT8 *outStatus);
Osamu Nakamura 0:8373b6833bde 169
Osamu Nakamura 0:8373b6833bde 170 #ifdef __cplusplus
Osamu Nakamura 0:8373b6833bde 171 }
Osamu Nakamura 0:8373b6833bde 172 #endif
Osamu Nakamura 0:8373b6833bde 173
Osamu Nakamura 0:8373b6833bde 174 #endif /* HVCApi_H__ */
Osamu Nakamura 0:8373b6833bde 175