Example program to create IoT devices for a local network, which connect to a local server.

Dependencies:   WebSocketClient WiflyInterface mbed messages

This code is used in the second part of my Internet of Things (IoT) blog post available here. The code is fairly simple, but its real value is in its reliability. I have worked hard to try to make the wireless connection as reliable, and as fast, as possible. There are a few lines of code that must be modified before it will work correctly, and those are described in the following Wiki pages.

It is designed to work with a Python WebSocket Server running on a PC, the source code of which is available here.

Once operating with the server, each microcontroller, or IoT device, will broadcast a counter and its internal temperature to your WebSocket Server.

headers/Commands.h

Committer:
defrost
Date:
2016-10-06
Revision:
5:0c7d131e6089
Parent:
1:4403f2ed1c1f
Child:
6:424e225d2a91

File content as of revision 5:0c7d131e6089:

// **************
// * Commands.h *
// **************
//
// Created: 2016/03/24
// By: Damien Frost
//
// Description:
// Status registers

#ifndef IQ_COMMANDS_H
#define IQ_COMMANDS_H

#include "StatusReg.h"
#include "globals.h"

#define BIT0    0x1 
#define BIT1    0x2 
#define BIT2    0x4 
#define BIT3    0x8 
#define BIT4    0x10 
#define BIT5    0x20 
#define BIT6    0x40 
#define BIT7    0x80 
#define BIT8    0x100 
#define BIT9    0x200 
#define BIT10   0x400 
#define BIT11   0x800 
#define BIT12   0x1000 
#define BIT13   0x2000 
#define BIT14   0x4000 
#define BIT15   0x8000 

#define BIT16   0x10000 
#define BIT17   0x20000 
#define BIT18   0x40000 
#define BIT19   0x80000 
#define BIT20   0x100000 
#define BIT21   0x200000 
#define BIT22   0x400000 
#define BIT23   0x800000 
#define BIT24   0x1000000 
#define BIT25   0x2000000 
#define BIT26   0x4000000 
#define BIT27   0x8000000 
#define BIT28   0x10000000 
#define BIT29   0x20000000 
#define BIT30   0x40000000 
#define BIT31   0x80000000 

// Status regsiter flags:
#define SF_SERVERCONNECTED      BIT0
#define SF_AUTOCONNECT          BIT1        // Set this flag to automatically start connecting to the websocket server
#define SF_WIRELESSCONNECTED    BIT2        // Flag to indicate whether or not the wireless network is connected
                                            
// Wifi Commands
#define     NO_WIFI_CMD         0
#define     CV_LED_WIFI_CMD     1

// Change variable commands:
#define     CV_LED              1

extern StatusReg IotStatus;

#endif  /* IQ_COMMANDS_H */