Thing+ Cloud service client library for W7500x MCU

This project describes that how to use the client library of Thing + on wiznet w7500 and how to utilize the Thing+ service.
ORIGINAL POST
By Eric Jung
components
Hardware Components
W7500x the Ethernet MCU ( W7500 / W7500P )
X 1
details

Overview

In this posting, we will introduce the client library of Thing + Cloud service that runs on WIZnet’s W7500x MCU. Thing + is a domestic company, DawWorks’ IoT Cloud platform service. It is based on easy and fast IoT service construction and supports various open source hardware (OSHW) such as Arduino and Beaglebone green.

SSL / TLS security support is required by default to work with the Thing + Cloud service. However, recently DaliWorks has provided a non-SSL port with Arduino thing + library for testing purposes for Arduino developers, so we have created a library that enables testing of Thing + Cloud in W7500x MCU.

The project code is based on the version 1.0.6 of Thing + Arduino library. We changed the existing library made in C ++ version to C and changed and ported various Arduino libraries to other available libraries.

For the subscription of Thing + service and registration of Gateway Device, please refer to ‘ User’s Guide of Arduino ‘ at the following link. 
Link: http://support.thingplus.net/en/open-hardware/arduino-noSSL-user-guide.html

Resources Link:
WIZnet Wiki Site: W7500x the Ethernet MCU ( W7500 / W7500P ) 
Unlike Works Website: http://www.daliworks.net
Thing, + Website: https://thingplus.net

 

Note: The code introduced in this article is written in C language based on Keil vision 5 and is designed to run on WIZnet’s W4500x based ARM Cortex-M0 based Ethernet MCU. However, because it is very simple and has little dependency on MCU if you use WIZnet’s Hardware TCP / IP core, you can easily port it.

 

Concept

  • Produced to be nearly identical to existing Arduino Thing + library
  • Portable C ++ code to C code, flexible to existing C-based development environment
  • Eclipse Paho MQTT client is used as MQTT client library, and commercial SSL / TLS security is added to create commercial IoT device that works with Thing + service

Porting

Configuring an Existing Arduino Library

thingplus_lib_stack_for_arduino

Change each part of existing Arduino library to available library and modify the behavior

  • MQTT Client:  PubSubClient library -> Eclipse Paho library
  • JSON Parser: ArduinoJSON library -> cJSON library
  • Other Ethernet and Time related libraries utilize W7500x Driver and WIZnet ioLibrary

Library configuration for W7500x and comparison with existing library

thingplus_lib_stack_for_w7500x

Source Code

debug_messages_for_trobleshooting

APIs

void thingplus_begin(uint8_t *mac, uint8_t *apikey)

   Description : Initialize the Thing+ library
   Parameter
        - mac : mac address
        - apikey : apikey generated by Thing+
                   You can get apikey from Thing+ Portal       

void thingplus_connect(void)

   Description : Connect Thing+ via MQTT
                 Before call this API, W7500x Device MUST CONNECT INTERNET.

void thingplus_disconnect(void)

   Description : Disconnecting Thing+

uint8_t thingplus_loop(void)

   Description : Doing MQTT related works.
                 W7500x Device MUST CALL THIS API PERIODICALLY

uint8_t thingplus_gatewayStatusPublish(uint8_t on, time_t durationSec)

   Description : Send gateway status to Thing+
   Parameter
      - on : True if gateway is on, false if gateway is off
      - validSec : Valid time. Unit is second.
                   You must resend the status before timeout.
                   If timeouted, the status is considered as error

uint8_t thingplus_sensorStatusPublish(const uint8_t *id, uint8_t on, time_t durationSec)

   Description : Send sensor status to Thing+
   Parameter
      - id : Sensor id.
      - on : True if sensor is on, false if sensor is off
      - validSec : Valid time. Unit is second.
                   You must resend the status before timeout.
                   If timeouted, the status is considered as error

uint8_t thingplus_valuePublish_str(const uint8_t *id, char *value)

   Description : Send sensor sting value to Thing+
   Parameter
      - id : Sensor id.
      - value : Sensor value

uint8_t thingplus_valuePublish_int(const uint8_t *id, int value)

   Description : Send sensor interger value to Thing+
   Parameter
      - id : Sensor id.
      - value : Sensor value

uint8_t thingplus_valuePublish_float(const uint8_t *id, float value)

   Description : Send sensor float value to Thing+
   Parameter
      - id : Sensor id.
      - value : Sensor value

uint8_t thingplus_actuatorCallbackSet(uint8_t* (cb)(const uint8_t id, const uint8_t* cmd, cJSON *options))

 Description : Register actuator callback function.
   Parameter
      - cb : Callback function pointer

Usage Comparison

Arduino Ver. VS WIZnet W7500x Ver.

  • Both the Arduino library and the implemented W7500x library work in almost the same main routine structure
  • If SSL / TLS support library is made later, the prototype structure in Arduino can be implemented in the same

usage_comparison

Thing+ Dashboard Example

demo_dashboard_for_wiz750sr

 

Source : https://ericslabs.wordpress.com/2016/10/10/thing-cloud-service-client-library-for-w7500x-mcu/

 

documents
Code
source cide

COMMENTS

Please Login to comment
  Subscribe  
Notify of