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:
Tue Oct 04 11:34:47 2016 +0000
Revision:
0:c5607b31fb07
Child:
6:424e225d2a91
- Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 0:c5607b31fb07 1 // ********************
defrost 0:c5607b31fb07 2 // * iQ_StatusReg.cpp *
defrost 0:c5607b31fb07 3 // ********************
defrost 0:c5607b31fb07 4 //
defrost 0:c5607b31fb07 5 // Created: 2016/03/24
defrost 0:c5607b31fb07 6 // By: Damien Frost
defrost 0:c5607b31fb07 7
defrost 0:c5607b31fb07 8
defrost 0:c5607b31fb07 9 #include "StatusReg.h"
defrost 0:c5607b31fb07 10
defrost 0:c5607b31fb07 11 StatusReg::StatusReg()
defrost 0:c5607b31fb07 12 {
defrost 0:c5607b31fb07 13 _reg = 0;
defrost 0:c5607b31fb07 14 return;
defrost 0:c5607b31fb07 15 }
defrost 0:c5607b31fb07 16
defrost 0:c5607b31fb07 17 // Set a flag:
defrost 0:c5607b31fb07 18 void StatusReg::SetFlag(unsigned int flag){
defrost 0:c5607b31fb07 19 _reg |= flag;
defrost 0:c5607b31fb07 20 return;
defrost 0:c5607b31fb07 21 }
defrost 0:c5607b31fb07 22
defrost 0:c5607b31fb07 23 // Clear a flag:
defrost 0:c5607b31fb07 24 void StatusReg::ClearFlag(unsigned int flag){
defrost 0:c5607b31fb07 25 _reg &= (~flag);
defrost 0:c5607b31fb07 26 return;
defrost 0:c5607b31fb07 27 }
defrost 0:c5607b31fb07 28
defrost 0:c5607b31fb07 29 // Check for flag
defrost 0:c5607b31fb07 30 bool StatusReg::CheckFlag(unsigned int flag){
defrost 0:c5607b31fb07 31 if((_reg & flag) > 0){
defrost 0:c5607b31fb07 32 return true;
defrost 0:c5607b31fb07 33 }else{
defrost 0:c5607b31fb07 34 return false;
defrost 0:c5607b31fb07 35 }
defrost 0:c5607b31fb07 36 }
defrost 0:c5607b31fb07 37
defrost 0:c5607b31fb07 38 // Check for no flags
defrost 0:c5607b31fb07 39 bool StatusReg::AllClear(void){
defrost 0:c5607b31fb07 40 if(_reg == 0){
defrost 0:c5607b31fb07 41 return true;
defrost 0:c5607b31fb07 42 }else{
defrost 0:c5607b31fb07 43 return false;
defrost 0:c5607b31fb07 44 }
defrost 0:c5607b31fb07 45 }
defrost 0:c5607b31fb07 46
defrost 0:c5607b31fb07 47 unsigned int StatusReg::GetReg(void){
defrost 0:c5607b31fb07 48 return _reg;
defrost 0:c5607b31fb07 49 }