Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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
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
- SharkMQ (Secure) Client Example
- SMQ LED Demonstration Tutorial
- SMQ Documentation
- Real Time Logic LLC public SMQ Broker access.
- How to set up your own low cost SMQ Broker cloud server solution Tutorial.
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.
Diff: SimpleMQ/src/seLwIP.c
- Revision:
- 2:bac2873dbd15
- Parent:
- 0:bd3aeb15634e
--- a/SimpleMQ/src/seLwIP.c Fri Jan 02 20:27:26 2015 +0000 +++ b/SimpleMQ/src/seLwIP.c Fri Mar 25 23:07:22 2016 +0000 @@ -10,9 +10,9 @@ **************************************************************************** * PROGRAM MODULE * - * $Id: seLwIP.c 3617 2014-12-03 23:38:39Z wini $ + * $Id: seLwIP.c 3749 2015-07-28 20:30:23Z wini $ * - * COPYRIGHT: Real Time Logic LLC, 2014 + * COPYRIGHT: Real Time Logic LLC, 2014 - 2015 * * This software is copyrighted by and is the sole property of Real * Time Logic LLC. All rights, title, ownership, or other interests in @@ -42,26 +42,35 @@ #endif +#if LWIP_SO_RCVTIMEO != 1 +#error LWIP_SO_RCVTIMEO must be set +#endif + +#ifndef netconn_set_recvtimeout +#define OLD_LWIP +#define netconn_set_recvtimeout(conn, timeout) \ + ((conn)->recv_timeout = (timeout)) +#endif + + + + int se_accept(SOCKET** listenSock, U32 timeout, SOCKET** outSock) { err_t err; memset(*outSock, 0, sizeof(SOCKET)); - if(timeout != INFINITE_TMO) - netconn_set_recvtimeout((*listenSock)->con, timeout); - L_accept: + netconn_set_recvtimeout( + (*listenSock)->con, timeout == INFINITE_TMO ? 0 : timeout); +#ifdef OLD_LWIP + (*outSock)->con = netconn_accept((*listenSock)->con); + err = (*outSock)->con->err; + if(!(*outSock)->con && !err) err = ERR_CONN; +#else err = netconn_accept((*listenSock)->con, &(*outSock)->con); +#endif if(err != ERR_OK) { - if(err == ERR_TIMEOUT) - { - if(timeout == INFINITE_TMO) - { - netconn_set_recvtimeout((*listenSock)->con, 100000); - goto L_accept; - } - return 0; - } - return -1; + return err == ERR_TIMEOUT ? 0 : -1; } return 1; } @@ -97,9 +106,11 @@ */ int se_connect(SOCKET* sock, const char* name, U16 port) { - - +#ifdef OLD_LWIP + struct ip_addr addr; +#else ip_addr_t addr; +#endif memset(sock, 0, sizeof(SOCKET)); if(netconn_gethostbyname(name, &addr) != ERR_OK) return -2; @@ -139,50 +150,39 @@ -S32 se_recv(SOCKET* sock, void* buf, U32 len, U32 timeout) +S32 se_recv(SOCKET* sock, void* data, U32 len, U32 timeout) { + int rlen; + netconn_set_recvtimeout(sock->con, timeout == INFINITE_TMO ? 0 : timeout); if( ! sock->nbuf ) { err_t err; - if(timeout != INFINITE_TMO) - netconn_set_recvtimeout(sock->con, timeout); - L_read: + sock->pbOffs = 0; +#ifdef OLD_LWIP + sock->nbuf = netconn_recv(sock->con); + err = sock->con->err; + if(!sock->nbuf && !err) err = ERR_CONN; +#else err = netconn_recv(sock->con, &sock->nbuf); - if(err != ERR_OK) +#endif + if(ERR_OK != err) { - if(err == ERR_TIMEOUT) - { - if(timeout == INFINITE_TMO) - { - netconn_set_recvtimeout(sock->con, 100000); - goto L_read; - } - return 0; - } - se_close(sock); - return (S32)err; + if(sock->nbuf) + netbuf_delete(sock->nbuf); + sock->nbuf=0; + return err == ERR_TIMEOUT ? 0 : (S32)err; } } - if( ! sock->data ) - netbuf_data(sock->nbuf, (void**)&sock->data, &sock->len); - if(sock->len <= len) + rlen=(int)netbuf_copy_partial(sock->nbuf,(U8*)data,len,sock->pbOffs); + if(!rlen) + return -1; + sock->pbOffs += rlen; + if(sock->pbOffs >= netbuf_len(sock->nbuf)) { - memcpy(buf,sock->data,sock->len); - sock->data=0; - if(netbuf_next(sock->nbuf) < 0) - { - netbuf_delete(sock->nbuf); - sock->nbuf=0; - } - len = sock->len; + netbuf_delete(sock->nbuf); + sock->nbuf=0; } - else - { - memcpy(buf,sock->data,len); - sock->data += len; - sock->len -= len; - } - return len; + return rlen; }