Dependencies:   EthernetInterface mbed-rtos mbed

Introduction

The SMQ Architecture is an Internet of Things (IoT) publish subscribe end-to-end solution that is optimized for embedded systems to provide instantaneous Device Edge Node connectivity, 1 to 1 Communications, and Ease of Transcending Firewalls. The solution is ideal for resource constrained devices that require real-time dynamic control, analytic information, and firmware updates in both LAN and WAN environments.

Architecture Component List

  • SMQ C Client (Non-secure)
  • SharkMQ (Secure) C Client
  • SMQjs (Javascript)
  • SMQ JAVA
  • SMQ Broker

/media/uploads/wini/smq_architecture.png

SMQ Client-example

A (non-secure) C Client implementation of the SMQ protocol demonstrating device control over the on board LEDs via any modern (WebSocket enabled) Browser interface.

  • Code Size: 3kB

See Also

How to setup your own SMQ IoT cloud server

Most IoT cloud server solutions, whether they provide ready-to-use hosted services or not, are based on a standard Virtual Private Server (VPS). Most developers probably think of Amazon or Microsoft Azure's services when considering the server side of their IoT solution. These high-end services are great if you need to scale up to millions of connected devices. However, for most small-scale operations and DIY projects, a low-cost VPS is more than adequate.

Committer:
wini
Date:
Mon May 23 14:13:28 2016 +0000
Revision:
5:bfd98bf43a59
Parent:
3:c718bd8c7b8f
Updated to include latest mbed release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wini 3:c718bd8c7b8f 1 /*
wini 3:c718bd8c7b8f 2 * ____ _________ __ _
wini 3:c718bd8c7b8f 3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
wini 3:c718bd8c7b8f 4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
wini 3:c718bd8c7b8f 5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
wini 3:c718bd8c7b8f 6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
wini 3:c718bd8c7b8f 7 * /____/
wini 3:c718bd8c7b8f 8 *
wini 3:c718bd8c7b8f 9 * SharkSSL Embedded SSL/TLS Stack
wini 3:c718bd8c7b8f 10 ****************************************************************************
wini 3:c718bd8c7b8f 11 * PROGRAM MODULE
wini 3:c718bd8c7b8f 12 *
wini 3:c718bd8c7b8f 13 * $Id: ledctrl.h 3836 2016-01-08 00:16:27Z wini $
wini 3:c718bd8c7b8f 14 *
wini 3:c718bd8c7b8f 15 * COPYRIGHT: Real Time Logic LLC, 2013 - 2015
wini 3:c718bd8c7b8f 16 *
wini 3:c718bd8c7b8f 17 * This software is copyrighted by and is the sole property of Real
wini 3:c718bd8c7b8f 18 * Time Logic LLC. All rights, title, ownership, or other interests in
wini 3:c718bd8c7b8f 19 * the software remain the property of Real Time Logic LLC. This
wini 3:c718bd8c7b8f 20 * software may only be used in accordance with the terms and
wini 3:c718bd8c7b8f 21 * conditions stipulated in the corresponding license agreement under
wini 3:c718bd8c7b8f 22 * which the software has been supplied. Any unauthorized use,
wini 3:c718bd8c7b8f 23 * duplication, transmission, distribution, or disclosure of this
wini 3:c718bd8c7b8f 24 * software is expressly forbidden.
wini 3:c718bd8c7b8f 25 *
wini 3:c718bd8c7b8f 26 * This Copyright notice may not be removed or modified without prior
wini 3:c718bd8c7b8f 27 * written consent of Real Time Logic LLC.
wini 3:c718bd8c7b8f 28 *
wini 3:c718bd8c7b8f 29 * Real Time Logic LLC. reserves the right to modify this software
wini 3:c718bd8c7b8f 30 * without notice.
wini 3:c718bd8c7b8f 31 *
wini 3:c718bd8c7b8f 32 * http://realtimelogic.com
wini 3:c718bd8c7b8f 33 * http://sharkssl.com
wini 3:c718bd8c7b8f 34 ****************************************************************************
wini 3:c718bd8c7b8f 35 *
wini 3:c718bd8c7b8f 36 */
wini 3:c718bd8c7b8f 37
wini 3:c718bd8c7b8f 38 #ifndef _ledctrl_h
wini 3:c718bd8c7b8f 39 #define _ledctrl_h
wini 3:c718bd8c7b8f 40
wini 3:c718bd8c7b8f 41 #include "selib.h"
wini 3:c718bd8c7b8f 42
wini 3:c718bd8c7b8f 43 /* Do not change the number sequence. Must match peer code. */
wini 3:c718bd8c7b8f 44 typedef enum
wini 3:c718bd8c7b8f 45 {
wini 3:c718bd8c7b8f 46 LedColor_red=0,
wini 3:c718bd8c7b8f 47 LedColor_yellow=1,
wini 3:c718bd8c7b8f 48 LedColor_green=2,
wini 3:c718bd8c7b8f 49 LedColor_blue=3
wini 3:c718bd8c7b8f 50 } LedColor;
wini 3:c718bd8c7b8f 51
wini 3:c718bd8c7b8f 52
wini 3:c718bd8c7b8f 53 /* Each LED is registered with the following information */
wini 3:c718bd8c7b8f 54 typedef struct {
wini 3:c718bd8c7b8f 55 const char* name; /* LED name shown in the browser */
wini 3:c718bd8c7b8f 56 LedColor color; /* The color of this particular LED */
wini 3:c718bd8c7b8f 57 int id; /* A unique ID for the LED. ID range can be 0 to 15. */
wini 3:c718bd8c7b8f 58 } LedInfo;
wini 3:c718bd8c7b8f 59
wini 3:c718bd8c7b8f 60
wini 3:c718bd8c7b8f 61 typedef enum {
wini 3:c718bd8c7b8f 62 ProgramStatus_Starting,
wini 3:c718bd8c7b8f 63 ProgramStatus_Restarting,
wini 3:c718bd8c7b8f 64 ProgramStatus_Connecting,
wini 3:c718bd8c7b8f 65 ProgramStatus_SslHandshake,
wini 3:c718bd8c7b8f 66 ProgramStatus_DeviceReady,
wini 3:c718bd8c7b8f 67 ProgramStatus_CloseCommandReceived,
wini 3:c718bd8c7b8f 68
wini 3:c718bd8c7b8f 69 ProgramStatus_SocketError,
wini 3:c718bd8c7b8f 70 ProgramStatus_DnsError,
wini 3:c718bd8c7b8f 71 ProgramStatus_ConnectionError,
wini 3:c718bd8c7b8f 72 ProgramStatus_CertificateNotTrustedError,
wini 3:c718bd8c7b8f 73 ProgramStatus_SslHandshakeError,
wini 3:c718bd8c7b8f 74 ProgramStatus_WebServiceNotAvailError,
wini 3:c718bd8c7b8f 75 ProgramStatus_PongResponseError,
wini 3:c718bd8c7b8f 76 ProgramStatus_InvalidCommandError,
wini 3:c718bd8c7b8f 77 ProgramStatus_MemoryError
wini 3:c718bd8c7b8f 78 } ProgramStatus;
wini 3:c718bd8c7b8f 79
wini 3:c718bd8c7b8f 80
wini 3:c718bd8c7b8f 81 #ifdef __cplusplus
wini 3:c718bd8c7b8f 82 extern "C" {
wini 3:c718bd8c7b8f 83 #endif
wini 3:c718bd8c7b8f 84
wini 3:c718bd8c7b8f 85 /*
wini 3:c718bd8c7b8f 86 Return an array of LedInfo (struct). Each element in the array
wini 3:c718bd8c7b8f 87 provides information for one LED. The 'len' argument must be set by
wini 3:c718bd8c7b8f 88 function getLedInfo. The out argument 'en' specifies the length of
wini 3:c718bd8c7b8f 89 the returned array, that is, number of LEDs in the device. Each LED
wini 3:c718bd8c7b8f 90 has a name, color, and ID. The ID, which provides information about
wini 3:c718bd8c7b8f 91 which LED to turn on/off, is used by control messages sent between
wini 3:c718bd8c7b8f 92 device code and UI clients. The IDs for a four LED device can for
wini 3:c718bd8c7b8f 93 example be 1,2,3,4.
wini 3:c718bd8c7b8f 94 */
wini 3:c718bd8c7b8f 95 const LedInfo* getLedInfo(int* len);
wini 3:c718bd8c7b8f 96
wini 3:c718bd8c7b8f 97
wini 3:c718bd8c7b8f 98 /* Returns the name of this device. The name is presented by UI
wini 3:c718bd8c7b8f 99 clients such as browsers.
wini 3:c718bd8c7b8f 100 */
wini 3:c718bd8c7b8f 101 const char* getDevName(void);
wini 3:c718bd8c7b8f 102
wini 3:c718bd8c7b8f 103
wini 3:c718bd8c7b8f 104 /* Command sent by UI client to turn LED with ID on or off. This
wini 3:c718bd8c7b8f 105 function must set the LED to on if 'on' is TRUE and off if 'on' is FALSE.
wini 3:c718bd8c7b8f 106 */
wini 3:c718bd8c7b8f 107 int setLed(int ledId, int on);
wini 3:c718bd8c7b8f 108
wini 3:c718bd8c7b8f 109 /*
wini 3:c718bd8c7b8f 110 An optional function that enables LEDs to be set directly by the
wini 3:c718bd8c7b8f 111 device. This function is typically used by devices that include one
wini 3:c718bd8c7b8f 112 or more buttons. A button click may for example turn on a specific
wini 3:c718bd8c7b8f 113 LED. The function is called at intervals (polled) by the LED device
wini 3:c718bd8c7b8f 114 code. The function may for example detect a button click and return
wini 3:c718bd8c7b8f 115 the information to the caller. Arguments 'ledId' and 'on' are out
wini 3:c718bd8c7b8f 116 arguments, where 'ledId' is set to the LED ID and 'on' is set to
wini 3:c718bd8c7b8f 117 TRUE for on and FALSE for off. The function must return TRUE (a non
wini 3:c718bd8c7b8f 118 zero value) if the LED is to be set on/off and zero on no
wini 3:c718bd8c7b8f 119 change. Create an empty function returning zero if you do not plan
wini 3:c718bd8c7b8f 120 on implementing this feature.
wini 3:c718bd8c7b8f 121 */
wini 3:c718bd8c7b8f 122 int setLedFromDevice(int* ledId, int* on);
wini 3:c718bd8c7b8f 123
wini 3:c718bd8c7b8f 124 /* Returns the LED on/off state for led with ID 'ledId'.
wini 3:c718bd8c7b8f 125 */
wini 3:c718bd8c7b8f 126 int getLedState(int ledId);
wini 3:c718bd8c7b8f 127
wini 3:c718bd8c7b8f 128 /*
wini 3:c718bd8c7b8f 129 The purpose with program status is to provide visible program
wini 3:c718bd8c7b8f 130 connection state information during startup. The function is typically
wini 3:c718bd8c7b8f 131 used to signal information via the LEDs. Simply create an empty
wini 3:c718bd8c7b8f 132 function if you do not want to set program status.
wini 3:c718bd8c7b8f 133 */
wini 3:c718bd8c7b8f 134 void setProgramStatus(ProgramStatus s);
wini 3:c718bd8c7b8f 135
wini 3:c718bd8c7b8f 136 /* Required by SMQ examples.
wini 3:c718bd8c7b8f 137 The unique ID is used when calling the SMQ constructor. The
wini 3:c718bd8c7b8f 138 unique ID is typically set to the MAC address. See the SMQ
wini 3:c718bd8c7b8f 139 documentation for details:
wini 3:c718bd8c7b8f 140 https://realtimelogic.com/ba/doc/en/C/shark/structSharkMQ.html
wini 3:c718bd8c7b8f 141 */
wini 3:c718bd8c7b8f 142 int getUniqueId(const char** id);
wini 3:c718bd8c7b8f 143
wini 3:c718bd8c7b8f 144 /* Optional function that can be implemented and used by the SMQ
wini 3:c718bd8c7b8f 145 examples if the device includes a temperature sensor. The returned
wini 3:c718bd8c7b8f 146 value must be in Celsius times 10 i.e. the temperature 20 Celsius
wini 3:c718bd8c7b8f 147 must be returned as the value 200. You must also compile the code
wini 3:c718bd8c7b8f 148 with the macro ENABLE_TEMP defined to enable the temperature
wini 3:c718bd8c7b8f 149 logic. The simulated (host) version includes a simulated
wini 3:c718bd8c7b8f 150 temperature and the temperature can be changed by using the up and
wini 3:c718bd8c7b8f 151 down keyboard arrows. The temperature is displayed in the browser UI.
wini 3:c718bd8c7b8f 152 */
wini 3:c718bd8c7b8f 153 int getTemp(void);
wini 3:c718bd8c7b8f 154
wini 3:c718bd8c7b8f 155
wini 3:c718bd8c7b8f 156 #ifdef __cplusplus
wini 3:c718bd8c7b8f 157 }
wini 3:c718bd8c7b8f 158 #endif
wini 3:c718bd8c7b8f 159
wini 3:c718bd8c7b8f 160 #endif
wini 3:c718bd8c7b8f 161