Real Time Logic LLC / Mbed 2 deprecated SMQ Client-example Featured

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:
Wed Dec 03 23:54:54 2014 +0000
Revision:
0:bd3aeb15634e
Child:
1:734fa1459f69
SimpleMQ IoT protocol: first release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wini 0:bd3aeb15634e 1
wini 0:bd3aeb15634e 2 #include "mbed.h"
wini 0:bd3aeb15634e 3 #include "ledctrl.h"
wini 0:bd3aeb15634e 4 #include "EthernetInterface.h"
wini 0:bd3aeb15634e 5
wini 0:bd3aeb15634e 6 DigitalOut led1(LED1);
wini 0:bd3aeb15634e 7
wini 0:bd3aeb15634e 8 //PATCH CTX
wini 0:bd3aeb15634e 9 extern "C" void mainTask(const char* uuid, int uuidLen, const char* devInfo);
wini 0:bd3aeb15634e 10
wini 0:bd3aeb15634e 11
wini 0:bd3aeb15634e 12 static const LedInfo ledInfo[] = {
wini 0:bd3aeb15634e 13 {
wini 0:bd3aeb15634e 14 "LED 1",
wini 0:bd3aeb15634e 15 LedColor_green,
wini 0:bd3aeb15634e 16 1
wini 0:bd3aeb15634e 17 }
wini 0:bd3aeb15634e 18 };
wini 0:bd3aeb15634e 19
wini 0:bd3aeb15634e 20
wini 0:bd3aeb15634e 21 extern "C" int
wini 0:bd3aeb15634e 22 ledState(int ledId, int on, int set)
wini 0:bd3aeb15634e 23 {
wini 0:bd3aeb15634e 24 static int leds[sizeof(ledInfo)/sizeof(ledInfo[1])];
wini 0:bd3aeb15634e 25 baAssert(ledId >= 1 && ledId <= sizeof(ledInfo)/sizeof(ledInfo[1]));
wini 0:bd3aeb15634e 26 if(set)
wini 0:bd3aeb15634e 27 leds[ledId-1] = on;
wini 0:bd3aeb15634e 28 return leds[ledId-1];
wini 0:bd3aeb15634e 29 }
wini 0:bd3aeb15634e 30
wini 0:bd3aeb15634e 31
wini 0:bd3aeb15634e 32 const LedInfo* getLedInfo(int* len)
wini 0:bd3aeb15634e 33 {
wini 0:bd3aeb15634e 34 *len = sizeof(ledInfo) / sizeof(ledInfo[0]);
wini 0:bd3aeb15634e 35 return ledInfo;
wini 0:bd3aeb15634e 36 }
wini 0:bd3aeb15634e 37
wini 0:bd3aeb15634e 38 extern "C" const char* getDevName(void)
wini 0:bd3aeb15634e 39 {
wini 0:bd3aeb15634e 40 return "mbed: Arch Pro";
wini 0:bd3aeb15634e 41 }
wini 0:bd3aeb15634e 42
wini 0:bd3aeb15634e 43 extern "C" int setLed(int ledId, int on)
wini 0:bd3aeb15634e 44 {
wini 0:bd3aeb15634e 45 led1 = on;
wini 0:bd3aeb15634e 46 ledState(ledId, on, TRUE);
wini 0:bd3aeb15634e 47 return 0;
wini 0:bd3aeb15634e 48 }
wini 0:bd3aeb15634e 49
wini 0:bd3aeb15634e 50
wini 0:bd3aeb15634e 51 extern "C" int setLedFromDevice(int* ledId, int* on)
wini 0:bd3aeb15634e 52 {
wini 0:bd3aeb15634e 53 return FALSE;
wini 0:bd3aeb15634e 54 }
wini 0:bd3aeb15634e 55
wini 0:bd3aeb15634e 56 extern "C" void setProgramStatus(ProgramStatus s)
wini 0:bd3aeb15634e 57 {
wini 0:bd3aeb15634e 58 }
wini 0:bd3aeb15634e 59
wini 0:bd3aeb15634e 60
wini 0:bd3aeb15634e 61 int main()
wini 0:bd3aeb15634e 62 {
wini 0:bd3aeb15634e 63 EthernetInterface eth;
wini 0:bd3aeb15634e 64 mainTask(eth.getMACAddress(), strlen(eth.getMACAddress()), getDevName());
wini 0:bd3aeb15634e 65 error("mainTask returned");
wini 0:bd3aeb15634e 66 }