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.

Committer:
defrost
Date:
Thu Oct 06 07:58:31 2016 +0000
Revision:
5:0c7d131e6089
Parent:
1:4403f2ed1c1f
Child:
6:424e225d2a91
- Added comments, cleaned up code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 1:4403f2ed1c1f 1 // **************
defrost 1:4403f2ed1c1f 2 // * Commands.h *
defrost 1:4403f2ed1c1f 3 // **************
defrost 1:4403f2ed1c1f 4 //
defrost 1:4403f2ed1c1f 5 // Created: 2016/03/24
defrost 1:4403f2ed1c1f 6 // By: Damien Frost
defrost 1:4403f2ed1c1f 7 //
defrost 1:4403f2ed1c1f 8 // Description:
defrost 1:4403f2ed1c1f 9 // Status registers
defrost 1:4403f2ed1c1f 10
defrost 1:4403f2ed1c1f 11 #ifndef IQ_COMMANDS_H
defrost 1:4403f2ed1c1f 12 #define IQ_COMMANDS_H
defrost 1:4403f2ed1c1f 13
defrost 1:4403f2ed1c1f 14 #include "StatusReg.h"
defrost 1:4403f2ed1c1f 15 #include "globals.h"
defrost 1:4403f2ed1c1f 16
defrost 1:4403f2ed1c1f 17 #define BIT0 0x1
defrost 1:4403f2ed1c1f 18 #define BIT1 0x2
defrost 1:4403f2ed1c1f 19 #define BIT2 0x4
defrost 1:4403f2ed1c1f 20 #define BIT3 0x8
defrost 1:4403f2ed1c1f 21 #define BIT4 0x10
defrost 1:4403f2ed1c1f 22 #define BIT5 0x20
defrost 1:4403f2ed1c1f 23 #define BIT6 0x40
defrost 1:4403f2ed1c1f 24 #define BIT7 0x80
defrost 1:4403f2ed1c1f 25 #define BIT8 0x100
defrost 1:4403f2ed1c1f 26 #define BIT9 0x200
defrost 1:4403f2ed1c1f 27 #define BIT10 0x400
defrost 1:4403f2ed1c1f 28 #define BIT11 0x800
defrost 1:4403f2ed1c1f 29 #define BIT12 0x1000
defrost 1:4403f2ed1c1f 30 #define BIT13 0x2000
defrost 1:4403f2ed1c1f 31 #define BIT14 0x4000
defrost 1:4403f2ed1c1f 32 #define BIT15 0x8000
defrost 1:4403f2ed1c1f 33
defrost 1:4403f2ed1c1f 34 #define BIT16 0x10000
defrost 1:4403f2ed1c1f 35 #define BIT17 0x20000
defrost 1:4403f2ed1c1f 36 #define BIT18 0x40000
defrost 1:4403f2ed1c1f 37 #define BIT19 0x80000
defrost 1:4403f2ed1c1f 38 #define BIT20 0x100000
defrost 1:4403f2ed1c1f 39 #define BIT21 0x200000
defrost 1:4403f2ed1c1f 40 #define BIT22 0x400000
defrost 1:4403f2ed1c1f 41 #define BIT23 0x800000
defrost 1:4403f2ed1c1f 42 #define BIT24 0x1000000
defrost 1:4403f2ed1c1f 43 #define BIT25 0x2000000
defrost 1:4403f2ed1c1f 44 #define BIT26 0x4000000
defrost 1:4403f2ed1c1f 45 #define BIT27 0x8000000
defrost 1:4403f2ed1c1f 46 #define BIT28 0x10000000
defrost 1:4403f2ed1c1f 47 #define BIT29 0x20000000
defrost 1:4403f2ed1c1f 48 #define BIT30 0x40000000
defrost 1:4403f2ed1c1f 49 #define BIT31 0x80000000
defrost 1:4403f2ed1c1f 50
defrost 1:4403f2ed1c1f 51 // Status regsiter flags:
defrost 1:4403f2ed1c1f 52 #define SF_SERVERCONNECTED BIT0
defrost 1:4403f2ed1c1f 53 #define SF_AUTOCONNECT BIT1 // Set this flag to automatically start connecting to the websocket server
defrost 1:4403f2ed1c1f 54 #define SF_WIRELESSCONNECTED BIT2 // Flag to indicate whether or not the wireless network is connected
defrost 1:4403f2ed1c1f 55
defrost 1:4403f2ed1c1f 56 // Wifi Commands
defrost 1:4403f2ed1c1f 57 #define NO_WIFI_CMD 0
defrost 5:0c7d131e6089 58 #define CV_LED_WIFI_CMD 1
defrost 1:4403f2ed1c1f 59
defrost 1:4403f2ed1c1f 60 // Change variable commands:
defrost 5:0c7d131e6089 61 #define CV_LED 1
defrost 1:4403f2ed1c1f 62
defrost 1:4403f2ed1c1f 63 extern StatusReg IotStatus;
defrost 1:4403f2ed1c1f 64
defrost 1:4403f2ed1c1f 65 #endif /* IQ_COMMANDS_H */