Skeleton program for Federico's 4YP project.

Dependencies:   WebSocketClient WiflyInterface mbed messages

Fork of IoT_Ex by Damien Frost

Committer:
defrost
Date:
Thu Oct 06 07:58:31 2016 +0000
Revision:
5:0c7d131e6089
Parent:
3:f20e114eb2ee
Child:
10:e8b66718a103
- Added comments, cleaned up code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 5:0c7d131e6089 1 /**
defrost 5:0c7d131e6089 2 * @author Damien Frost
defrost 5:0c7d131e6089 3 *
defrost 5:0c7d131e6089 4 * @section LICENSE
defrost 5:0c7d131e6089 5 *
defrost 5:0c7d131e6089 6 * Copyright (c) 2016 Damien Frost
defrost 5:0c7d131e6089 7 *
defrost 5:0c7d131e6089 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
defrost 5:0c7d131e6089 9 * of this software and associated documentation files (the "Software"), to deal
defrost 5:0c7d131e6089 10 * in the Software without restriction, including without limitation the rights
defrost 5:0c7d131e6089 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
defrost 5:0c7d131e6089 12 * copies of the Software, and to permit persons to whom the Software is
defrost 5:0c7d131e6089 13 * furnished to do so, subject to the following conditions:
defrost 5:0c7d131e6089 14 *
defrost 5:0c7d131e6089 15 * The above copyright notice and this permission notice shall be included in
defrost 5:0c7d131e6089 16 * all copies or substantial portions of the Software.
defrost 5:0c7d131e6089 17 *
defrost 5:0c7d131e6089 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
defrost 5:0c7d131e6089 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
defrost 5:0c7d131e6089 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
defrost 5:0c7d131e6089 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
defrost 5:0c7d131e6089 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
defrost 5:0c7d131e6089 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
defrost 5:0c7d131e6089 24 * THE SOFTWARE.
defrost 5:0c7d131e6089 25 *
defrost 5:0c7d131e6089 26 * @file "globals.h"
defrost 5:0c7d131e6089 27 *
defrost 5:0c7d131e6089 28 * @section DESCRIPTION
defrost 5:0c7d131e6089 29 * Global definitions for the Internet of Things example.
defrost 5:0c7d131e6089 30 *
defrost 5:0c7d131e6089 31 */
defrost 1:4403f2ed1c1f 32
defrost 1:4403f2ed1c1f 33 #ifndef IQ_GLOBALS_H
defrost 1:4403f2ed1c1f 34 #define IQ_GLOBALS_H
defrost 1:4403f2ed1c1f 35
defrost 1:4403f2ed1c1f 36 #include "mbed.h"
defrost 1:4403f2ed1c1f 37 #include "WiflyInterface.h"
defrost 1:4403f2ed1c1f 38 #include "Commands.h"
defrost 1:4403f2ed1c1f 39 #include "Websocket.h"
defrost 1:4403f2ed1c1f 40
defrost 1:4403f2ed1c1f 41
defrost 1:4403f2ed1c1f 42 // Wifi Interface defines:
defrost 1:4403f2ed1c1f 43 #define TCP_SERVER_PORT 4445
defrost 1:4403f2ed1c1f 44 #define WIFIBAUDRATE 115200
defrost 1:4403f2ed1c1f 45 #define WIFINETWORK 2
defrost 1:4403f2ed1c1f 46 #define CHARMSGBUFF 1024
defrost 1:4403f2ed1c1f 47 #define TIMEOUTRECEIVEATTEMPTS 5
defrost 1:4403f2ed1c1f 48 #define WS_PORT 4444
defrost 3:f20e114eb2ee 49 #define SERVER_IP "192.168.1.99"
defrost 1:4403f2ed1c1f 50
defrost 5:0c7d131e6089 51 // Hardware:
defrost 1:4403f2ed1c1f 52 extern Serial pc;
defrost 1:4403f2ed1c1f 53 extern InterruptIn UIBut1;
defrost 1:4403f2ed1c1f 54 extern Timer DisplayTimer;
defrost 2:7abdaa5a9209 55 extern DigitalOut Led;
defrost 1:4403f2ed1c1f 56
defrost 5:0c7d131e6089 57 // Variables:
defrost 1:4403f2ed1c1f 58 extern int ReconnectAttempts;
defrost 1:4403f2ed1c1f 59 extern int SendCounter;
defrost 1:4403f2ed1c1f 60 extern int IoT_ID;
defrost 1:4403f2ed1c1f 61 extern float TempSensor;
defrost 5:0c7d131e6089 62 extern char* wifissid;
defrost 5:0c7d131e6089 63 extern char* wifipassword;
defrost 1:4403f2ed1c1f 64
defrost 5:0c7d131e6089 65 // Communication:
defrost 5:0c7d131e6089 66 extern WiflyInterface eth;
defrost 1:4403f2ed1c1f 67 extern Websocket ws;
defrost 1:4403f2ed1c1f 68
defrost 1:4403f2ed1c1f 69 // Functions:
defrost 1:4403f2ed1c1f 70 void SensorToPu(float gain, float offset, int sensor, float* result);
defrost 1:4403f2ed1c1f 71 void InitializeStruct(struct tf_history_t* toClear);
defrost 1:4403f2ed1c1f 72 void SetupVar(void);
defrost 1:4403f2ed1c1f 73 void SetButtonEvent(void);
defrost 1:4403f2ed1c1f 74 void rt_OneStep(void);
defrost 1:4403f2ed1c1f 75 void DisplayInputs(float CPS);
defrost 1:4403f2ed1c1f 76 void SetSCKDCParams(bool enable, float gain);
defrost 1:4403f2ed1c1f 77 int SetupNetwork(int Tries);
defrost 1:4403f2ed1c1f 78 bool ConnectToServer(int Tries);
defrost 1:4403f2ed1c1f 79 void SendNetworkData(void);
defrost 5:0c7d131e6089 80 void ReceiveNetworkData(unsigned int * wifi_cmd, float * value);
defrost 1:4403f2ed1c1f 81 void ModifyVariable(unsigned int wifi_var, float wifi_data);
defrost 1:4403f2ed1c1f 82
defrost 1:4403f2ed1c1f 83
defrost 1:4403f2ed1c1f 84 #endif /* IQ_GLOBALS_H */
defrost 1:4403f2ed1c1f 85