This program connects to a few sensors via I2C and sends the data collected to a WNC Cellular Module which is located on an Avnet WNC-Shield card.

Dependencies:   FXOS8700CQ MODSERIAL mbed

/media/uploads/kevinkeryk/avnet_logo_tagline_rgb.png

Avnet Cellular IoT Instructions

  • One problematic area is setting the MY_SERVER_URL. When you copy the URL from the flow, you must make sure the MY_SERVER_URL is also set to the appropriate server. It can be either "run-east.att.io" or "run-west.att.io".

Useful Links

Adding Additional Sensors

The FLOW_DEVICE_NAME field must contain the name of the instance of the Virtual Starter Kit in FLOW you will be communicating with. Usually this is "vstarterkit001", but if you have problems communicating you can verify this is correct. Note: This device will not be created until you click the “Initialize” input on the Virtual Device tab of the Starter Kit project in FLOW. At that point, it becomes available in M2X and you can see it as the DEVICE SERIAL field under Devices as in the image below. /media/uploads/JMF/vstarterkit.png

Sensors: When executing, the FRDM-K64F board uploads sensor measurements to AT&T’s Flow environment every 5 seconds, using the Cellular shield board. You can adjust how often you want to do this by editing the SENSOR_UPDATE_INTERVAL_MS value in the header file.

Temperature and humidity: By default, the board reports readings from the HTS221 temperature and humidity sensor. These two values are sent to the HTTP IN /climate port in FLOW with field names “temp” and “humidity”. Temperature is in degrees Fahrenheit and humidity is a %. This default assignment is: iSensorsToReport = TEMP_HUMIDITY_ONLY;

Accelerometer: If you want to expand and use the onboard motion sensor, you can also send 3-axis accelerometer information from the board as “accelX”, “accelY”, and “accelZ”. This is useful if you want to know the stationary position of the board with regards to gravity, or whether it is in motion. These readings are in g’s. To send these values, change the assignment to: iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER;

PMOD Sensors: If you have a Silicon Labs sensor module that can plug into the PMOD connector on the Cellular shield, you are able to measure proximity, UV light, ambient visible and infrared light from the Si1145 sensor. This PMOD also has a temperature and humidity sensor, but in this case it is redundant. When enabled, the fields “proximity”, “light_uv”, “light_vis” and “light_ir” are also sent. To enable all these sensors, change the assignment to: iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS;

Connecting the PMOD sensors: Because the pinouts do not align, the SiLabs PMOD sensor board cannot be plugged into the J10 PMOD receptacle on the shield directly. The following wiring instructions must be followed:

SignalJ10ShieldPMOD Color in the image below
VCCPin 6Pin 6Red
GNDPin 5Pin 5Black
SDAPin4Pin 3Green
SCLPin3Pin 2Yellow

/media/uploads/JMF/xyz.jpg

AT&T M2X and FLOW Instructions

M2X & FLOW Instructions

Link to AT&T M2X

M2X

Link to AT&T Flow

FLOW

Avnet WNC-Shield Information

Getting Started with the Avnet WNC-Shield Software

  • This project uses Revision 119 of the MBED library because of I2C implementation differences with the tip (Revision 121).
  • This project uses Revision 4 of the FXOS8700CQ library for sensors.

Easily Modifiable Parameters

Inside the mbed Avnet_ATT_Cellular_IOT project, the parameters needed to customize your board are in the config_me.h file.

  • FLOW parameters: This project assumes you are using a fork of the Starter Kit Base project, which is a reference design created using AT&T’s FLOW (https://flow.att.com) that allows the creation of online virtualization and other IoT functionality. The default parameters in the config_me.h file are done for a specific instance of this project. When you fork the original project, you get your own instance and it will have its own base address. At the bottom of the FLOW environment, when you click on the Endpoints tab, URL information that is specific to your instance is displayed. Of note is the Base URL. In the example below (as in the default mbed project), the Base URL is: https://run-west.att.io/1e464b19cdcde/774c88d68202/86694923d5bf28a/in/flow You have to take note of two parts of this address. The run-west.att.io part is the server URL, and you have to make sure the
  • MY_SERVER_URL field in config_me.h matches this. The rest of the base URL, in green above, needs to be pasted into the FLOW_BASE_URL field.

There is also a FLOW_INPUT_NAME field. This should match the name of the HTTP IN port in the FLOW project that you want to send sensor data to. The default is "/climate", as in the FLOW image below.

/media/uploads/JMF/sf.png

Where is the Binary I compiled

When the COMPILE button is pressed, it compiles your project and links it. The result is placed in the DOWNLOAD folder you use when downloading files from the Internet. It will be called AvnetATT_shape_hackathon_K64F.bin.

Additional Information on Compiling/Configuring

Comprehensive instructions can be found at: Quick Start Instructions

Committer:
stefanrousseau
Date:
Thu Jul 28 15:52:37 2016 +0000
Revision:
55:3abf9e3f42e6
Parent:
53:dcccf2881fa0
Child:
56:cb42ff383dab
Added virtual sensors.  This uses the USB Rx unless you un-comment USE_VIRTUAL_SENSORS.  Also reverted to mbed 119 because of problems.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stefanrousseau 55:3abf9e3f42e6 1 #include "mbed.h"
JMF 0:9d5134074d84 2 #include <cctype>
JMF 0:9d5134074d84 3 #include <string>
JMF 0:9d5134074d84 4 #include "SerialBuffered.h"
JMF 0:9d5134074d84 5 #include "HTS221.h"
JMF 2:0e2ef866af95 6 #include "config_me.h"
JMF 2:0e2ef866af95 7 #include "wnc_control.h"
stefanrousseau 4:f83bedd9cab4 8 #include "sensors.h"
JMF 0:9d5134074d84 9
stefanrousseau 11:e6602513730f 10 #include "hardware.h"
stefanrousseau 11:e6602513730f 11 I2C i2c(PTC11, PTC10); //SDA, SCL -- define the I2C pins being used
stefanrousseau 11:e6602513730f 12
JMF 0:9d5134074d84 13 // comment out the following line if color is not supported on the terminal
JMF 0:9d5134074d84 14 #define USE_COLOR
JMF 0:9d5134074d84 15 #ifdef USE_COLOR
JMF 0:9d5134074d84 16 #define BLK "\033[30m"
JMF 0:9d5134074d84 17 #define RED "\033[31m"
JMF 0:9d5134074d84 18 #define GRN "\033[32m"
JMF 0:9d5134074d84 19 #define YEL "\033[33m"
JMF 0:9d5134074d84 20 #define BLU "\033[34m"
JMF 0:9d5134074d84 21 #define MAG "\033[35m"
JMF 0:9d5134074d84 22 #define CYN "\033[36m"
JMF 0:9d5134074d84 23 #define WHT "\033[37m"
JMF 0:9d5134074d84 24 #define DEF "\033[39m"
JMF 0:9d5134074d84 25 #else
JMF 0:9d5134074d84 26 #define BLK
JMF 0:9d5134074d84 27 #define RED
JMF 0:9d5134074d84 28 #define GRN
JMF 0:9d5134074d84 29 #define YEL
JMF 0:9d5134074d84 30 #define BLU
JMF 0:9d5134074d84 31 #define MAG
JMF 0:9d5134074d84 32 #define CYN
JMF 0:9d5134074d84 33 #define WHT
JMF 0:9d5134074d84 34 #define DEF
JMF 0:9d5134074d84 35 #endif
JMF 0:9d5134074d84 36
JMF 0:9d5134074d84 37 #define MDM_DBG_OFF 0
JMF 0:9d5134074d84 38 #define MDM_DBG_AT_CMDS (1 << 0)
JMF 0:9d5134074d84 39 int mdm_dbgmask = MDM_DBG_OFF;
JMF 0:9d5134074d84 40
fkellermavnet 33:fa964b8b3b19 41 #define WNC_WAIT_FOR_AT_CMD_MS 40
fkellermavnet 33:fa964b8b3b19 42
JMF 0:9d5134074d84 43 Serial pc(USBTX, USBRX);
fkellermavnet 38:564b312a719f 44 SerialBuffered mdm(PTD3, PTD2, 4096);
stefanrousseau 16:17c5916f2d12 45 DigitalOut led_green(LED_GREEN);
stefanrousseau 16:17c5916f2d12 46 DigitalOut led_red(LED_RED);
stefanrousseau 16:17c5916f2d12 47 DigitalOut led_blue(LED_BLUE);
JMF 0:9d5134074d84 48
JMF 0:9d5134074d84 49 DigitalOut mdm_uart2_rx_boot_mode_sel(PTC17); // on powerup, 0 = boot mode, 1 = normal boot
JMF 0:9d5134074d84 50 DigitalOut mdm_power_on(PTB9); // 0 = turn modem on, 1 = turn modem off (should be held high for >5 seconds to cycle modem)
JMF 0:9d5134074d84 51 DigitalOut mdm_wakeup_in(PTC2); // 0 = let modem sleep, 1 = keep modem awake -- Note: pulled high on shield
JMF 0:9d5134074d84 52
fkellermavnet 14:0c353e212296 53 DigitalOut mdm_reset(PTC12); // active high
fkellermavnet 14:0c353e212296 54
JMF 0:9d5134074d84 55 DigitalOut shield_3v3_1v8_sig_trans_ena(PTC4); // 0 = disabled (all signals high impedence, 1 = translation active
JMF 0:9d5134074d84 56 DigitalOut mdm_uart1_cts(PTD0);
JMF 0:9d5134074d84 57
JMF 0:9d5134074d84 58 #define TOUPPER(a) (a) //toupper(a)
JMF 0:9d5134074d84 59
JMF 0:9d5134074d84 60 const char ok_str[] = "OK";
JMF 0:9d5134074d84 61 const char error_str[] = "ERROR";
JMF 0:9d5134074d84 62
JMF 0:9d5134074d84 63 #define MDM_OK 0
JMF 0:9d5134074d84 64 #define MDM_ERR_TIMEOUT -1
JMF 0:9d5134074d84 65
JMF 0:9d5134074d84 66 #define MAX_AT_RSP_LEN 255
JMF 0:9d5134074d84 67
JMF 0:9d5134074d84 68 ssize_t mdm_getline(char *buff, size_t size, int timeout_ms) {
JMF 0:9d5134074d84 69 int cin = -1;
JMF 0:9d5134074d84 70 int cin_last;
JMF 0:9d5134074d84 71
JMF 0:9d5134074d84 72 if (NULL == buff || size == 0) {
JMF 0:9d5134074d84 73 return -1;
JMF 0:9d5134074d84 74 }
JMF 0:9d5134074d84 75
JMF 0:9d5134074d84 76 size_t len = 0;
JMF 0:9d5134074d84 77 Timer timer;
JMF 0:9d5134074d84 78 timer.start();
JMF 0:9d5134074d84 79 while ((len < (size-1)) && (timer.read_ms() < timeout_ms)) {
JMF 0:9d5134074d84 80 if (mdm.readable()) {
JMF 0:9d5134074d84 81 cin_last = cin;
JMF 0:9d5134074d84 82 cin = mdm.getc();
JMF 0:9d5134074d84 83 if (isprint(cin)) {
JMF 0:9d5134074d84 84 buff[len++] = (char)cin;
JMF 0:9d5134074d84 85 continue;
JMF 0:9d5134074d84 86 } else if (('\r' == cin_last) && ('\n' == cin)) {
JMF 0:9d5134074d84 87 break;
JMF 0:9d5134074d84 88 }
JMF 0:9d5134074d84 89 }
fkellermavnet 32:1e052a3e73fe 90 // wait_ms(1);
JMF 0:9d5134074d84 91 }
JMF 2:0e2ef866af95 92 buff[len] = (char)NULL;
JMF 0:9d5134074d84 93
JMF 0:9d5134074d84 94 return len;
JMF 0:9d5134074d84 95 }
JMF 0:9d5134074d84 96
JMF 0:9d5134074d84 97 int mdm_sendAtCmd(const char *cmd, const char **rsp_list, int timeout_ms) {
fkellermavnet 32:1e052a3e73fe 98 // Per WNC wait:
fkellermavnet 33:fa964b8b3b19 99 wait_ms(WNC_WAIT_FOR_AT_CMD_MS);
fkellermavnet 32:1e052a3e73fe 100
JMF 0:9d5134074d84 101 if (cmd && strlen(cmd) > 0) {
JMF 0:9d5134074d84 102 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
JMF 0:9d5134074d84 103 printf(MAG "ATCMD: " DEF "--> " GRN "%s" DEF "\n", cmd);
JMF 0:9d5134074d84 104 }
fkellermavnet 32:1e052a3e73fe 105 mdm.puts(cmd);
fkellermavnet 32:1e052a3e73fe 106 mdm.puts("\r\n");
JMF 0:9d5134074d84 107 }
fkellermavnet 32:1e052a3e73fe 108
JMF 0:9d5134074d84 109 if (rsp_list) {
JMF 0:9d5134074d84 110 Timer timer;
JMF 0:9d5134074d84 111 char rsp[MAX_AT_RSP_LEN+1];
JMF 0:9d5134074d84 112 int len;
JMF 0:9d5134074d84 113
JMF 0:9d5134074d84 114 timer.start();
JMF 0:9d5134074d84 115 while (timer.read_ms() < timeout_ms) {
JMF 0:9d5134074d84 116 len = mdm_getline(rsp, sizeof(rsp), timeout_ms - timer.read_ms());
JMF 0:9d5134074d84 117
JMF 0:9d5134074d84 118 if (len < 0)
JMF 0:9d5134074d84 119 return MDM_ERR_TIMEOUT;
JMF 0:9d5134074d84 120
JMF 0:9d5134074d84 121 if (len == 0)
JMF 0:9d5134074d84 122 continue;
JMF 0:9d5134074d84 123
JMF 0:9d5134074d84 124 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
JMF 0:9d5134074d84 125 printf(MAG "ATRSP: " DEF "<-- " CYN "%s" DEF "\n", rsp);
JMF 0:9d5134074d84 126 }
JMF 0:9d5134074d84 127
JMF 0:9d5134074d84 128 if (rsp_list) {
JMF 0:9d5134074d84 129 int rsp_idx = 0;
JMF 0:9d5134074d84 130 while (rsp_list[rsp_idx]) {
JMF 0:9d5134074d84 131 if (strcasecmp(rsp, rsp_list[rsp_idx]) == 0) {
JMF 0:9d5134074d84 132 return rsp_idx;
JMF 0:9d5134074d84 133 }
JMF 0:9d5134074d84 134 rsp_idx++;
JMF 0:9d5134074d84 135 }
JMF 0:9d5134074d84 136 }
JMF 0:9d5134074d84 137 }
JMF 0:9d5134074d84 138 return MDM_ERR_TIMEOUT;
JMF 0:9d5134074d84 139 }
JMF 0:9d5134074d84 140 return MDM_OK;
JMF 0:9d5134074d84 141 }
JMF 0:9d5134074d84 142
JMF 0:9d5134074d84 143 int mdm_init(void) {
fkellermavnet 14:0c353e212296 144 // Hard reset the modem (doesn't go through
fkellermavnet 14:0c353e212296 145 // the signal level translator)
fkellermavnet 14:0c353e212296 146 mdm_reset = 0;
JMF 17:38a8cc0c6ba5 147
JMF 17:38a8cc0c6ba5 148 // disable signal level translator (necessary
JMF 17:38a8cc0c6ba5 149 // for the modem to boot properly). All signals
JMF 17:38a8cc0c6ba5 150 // except mdm_reset go through the level translator
JMF 17:38a8cc0c6ba5 151 // and have internal pull-up/down in the module. While
JMF 17:38a8cc0c6ba5 152 // the level translator is disabled, these pins will
JMF 17:38a8cc0c6ba5 153 // be in the correct state.
JMF 17:38a8cc0c6ba5 154 shield_3v3_1v8_sig_trans_ena = 0;
JMF 17:38a8cc0c6ba5 155
JMF 17:38a8cc0c6ba5 156 // While the level translator is disabled and ouptut pins
JMF 17:38a8cc0c6ba5 157 // are tristated, make sure the inputs are in the same state
JMF 17:38a8cc0c6ba5 158 // as the WNC Module pins so that when the level translator is
JMF 17:38a8cc0c6ba5 159 // enabled, there are no differences.
JMF 17:38a8cc0c6ba5 160 mdm_uart2_rx_boot_mode_sel = 1; // UART2_RX should be high
JMF 17:38a8cc0c6ba5 161 mdm_power_on = 0; // powr_on should be low
JMF 17:38a8cc0c6ba5 162 mdm_wakeup_in = 1; // wake-up should be high
JMF 17:38a8cc0c6ba5 163 mdm_uart1_cts = 0; // indicate that it is ok to send
JMF 17:38a8cc0c6ba5 164
JMF 17:38a8cc0c6ba5 165 // Now, wait for the WNC Module to perform its initial boot correctly
fkellermavnet 14:0c353e212296 166 wait(1.0);
JMF 17:38a8cc0c6ba5 167
JMF 17:38a8cc0c6ba5 168 // The WNC module initializes comms at 115200 8N1 so set it up
JMF 17:38a8cc0c6ba5 169 mdm.baud(115200);
JMF 0:9d5134074d84 170
JMF 17:38a8cc0c6ba5 171 //Now, enable the level translator, the input pins should now be the
JMF 17:38a8cc0c6ba5 172 //same as how the M14A module is driving them with internal pull ups/downs.
JMF 17:38a8cc0c6ba5 173 //When enabled, there will be no changes in these 4 pins...
JMF 17:38a8cc0c6ba5 174 shield_3v3_1v8_sig_trans_ena = 1;
JMF 2:0e2ef866af95 175
fkellermavnet 53:dcccf2881fa0 176 // Now, give the modem 60 seconds to start responding by
JMF 0:9d5134074d84 177 // sending simple 'AT' commands to modem once per second.
JMF 0:9d5134074d84 178 Timer timer;
JMF 0:9d5134074d84 179 timer.start();
JMF 0:9d5134074d84 180 while (timer.read() < 60) {
JMF 0:9d5134074d84 181 const char * rsp_lst[] = { ok_str, error_str, NULL };
JMF 0:9d5134074d84 182 int rc = mdm_sendAtCmd("AT", rsp_lst, 500);
JMF 0:9d5134074d84 183 if (rc == 0)
fkellermavnet 14:0c353e212296 184 return true; //timer.read();
JMF 0:9d5134074d84 185 wait_ms(1000 - (timer.read_ms() % 1000));
JMF 0:9d5134074d84 186 pc.printf("\r%d",timer.read_ms()/1000);
JMF 0:9d5134074d84 187 }
JMF 0:9d5134074d84 188 return false;
JMF 0:9d5134074d84 189 }
JMF 0:9d5134074d84 190
JMF 2:0e2ef866af95 191 int mdm_sendAtCmdRsp(const char *cmd, const char **rsp_list, int timeout_ms, string * rsp, int * len) {
JMF 2:0e2ef866af95 192 static char cmd_buf[3200]; // Need enough room for the WNC sockreads (over 3000 chars)
fkellermavnet 6:713b4cbf1a7d 193 size_t n = strlen(cmd);
fkellermavnet 32:1e052a3e73fe 194
fkellermavnet 32:1e052a3e73fe 195 // Per WNC wait:
fkellermavnet 33:fa964b8b3b19 196 wait_ms(WNC_WAIT_FOR_AT_CMD_MS);
fkellermavnet 32:1e052a3e73fe 197
fkellermavnet 6:713b4cbf1a7d 198 if (cmd && n > 0) {
JMF 2:0e2ef866af95 199 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
JMF 2:0e2ef866af95 200 printf(MAG "ATCMD: " DEF "--> " GRN "%s" DEF "\n", cmd);
JMF 2:0e2ef866af95 201 }
fkellermavnet 43:6821a9c78c4b 202 // mdm.puts(cmd);
fkellermavnet 43:6821a9c78c4b 203 // mdm.puts("\r\n");
fkellermavnet 43:6821a9c78c4b 204 while (n--) {
fkellermavnet 43:6821a9c78c4b 205 mdm.putc(*cmd++);
fkellermavnet 43:6821a9c78c4b 206 wait_us(1000);
fkellermavnet 43:6821a9c78c4b 207 };
fkellermavnet 43:6821a9c78c4b 208 mdm.putc('\r');
fkellermavnet 43:6821a9c78c4b 209 wait_us(1000);
fkellermavnet 43:6821a9c78c4b 210 mdm.putc('\n');
fkellermavnet 43:6821a9c78c4b 211 wait_us(1000);
JMF 2:0e2ef866af95 212 }
JMF 2:0e2ef866af95 213
JMF 2:0e2ef866af95 214 if (rsp_list) {
JMF 2:0e2ef866af95 215 rsp->erase(); // Clean up from prior cmd response
JMF 2:0e2ef866af95 216 *len = 0;
JMF 2:0e2ef866af95 217 Timer timer;
JMF 2:0e2ef866af95 218 timer.start();
JMF 2:0e2ef866af95 219 while (timer.read_ms() < timeout_ms) {
JMF 2:0e2ef866af95 220 int lenCmd = mdm_getline(cmd_buf, sizeof(cmd_buf), timeout_ms - timer.read_ms());
JMF 2:0e2ef866af95 221
JMF 2:0e2ef866af95 222 if (lenCmd == 0)
JMF 2:0e2ef866af95 223 continue;
JMF 2:0e2ef866af95 224
JMF 2:0e2ef866af95 225 if (lenCmd < 0)
JMF 2:0e2ef866af95 226 return MDM_ERR_TIMEOUT;
JMF 2:0e2ef866af95 227 else {
JMF 2:0e2ef866af95 228 *len += lenCmd;
JMF 2:0e2ef866af95 229 *rsp += cmd_buf;
JMF 2:0e2ef866af95 230 }
JMF 2:0e2ef866af95 231
JMF 2:0e2ef866af95 232 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
JMF 2:0e2ef866af95 233 printf(MAG "ATRSP: " DEF "<-- " CYN "%s" DEF "\n", cmd_buf);
JMF 2:0e2ef866af95 234 }
JMF 2:0e2ef866af95 235
JMF 2:0e2ef866af95 236 int rsp_idx = 0;
JMF 2:0e2ef866af95 237 while (rsp_list[rsp_idx]) {
JMF 2:0e2ef866af95 238 if (strcasecmp(cmd_buf, rsp_list[rsp_idx]) == 0) {
JMF 2:0e2ef866af95 239 return rsp_idx;
JMF 2:0e2ef866af95 240 }
JMF 2:0e2ef866af95 241 rsp_idx++;
JMF 2:0e2ef866af95 242 }
JMF 2:0e2ef866af95 243 }
JMF 2:0e2ef866af95 244 return MDM_ERR_TIMEOUT;
JMF 2:0e2ef866af95 245 }
fkellermavnet 53:dcccf2881fa0 246
JMF 2:0e2ef866af95 247 return MDM_OK;
JMF 2:0e2ef866af95 248 }
JMF 2:0e2ef866af95 249
JMF 2:0e2ef866af95 250 void reinitialize_mdm(void)
JMF 2:0e2ef866af95 251 {
JMF 2:0e2ef866af95 252 // Initialize the modem
JMF 2:0e2ef866af95 253 printf(GRN "Modem RE-initializing..." DEF "\r\n");
JMF 2:0e2ef866af95 254 if (!mdm_init()) {
JMF 2:0e2ef866af95 255 printf(RED "\n\rModem RE-initialization failed!" DEF "\n");
JMF 2:0e2ef866af95 256 }
JMF 2:0e2ef866af95 257 printf("\r\n");
JMF 2:0e2ef866af95 258 }
JMF 2:0e2ef866af95 259 // These are built on the fly
JMF 2:0e2ef866af95 260 string MyServerIpAddress;
JMF 2:0e2ef866af95 261 string MySocketData;
JMF 2:0e2ef866af95 262
JMF 2:0e2ef866af95 263 // These are to be built on the fly
JMF 2:0e2ef866af95 264 string my_temp;
JMF 2:0e2ef866af95 265 string my_humidity;
JMF 2:0e2ef866af95 266
JMF 0:9d5134074d84 267 #define CTOF(x) ((x)*1.8+32)
JMF 0:9d5134074d84 268
stefanrousseau 3:26b3cc155f39 269 //********************************************************************************************************************************************
stefanrousseau 12:7c94ec5069dc 270 //* Create string with sensor readings that can be sent to flow as an HTTP get
stefanrousseau 3:26b3cc155f39 271 //********************************************************************************************************************************************
stefanrousseau 12:7c94ec5069dc 272 K64F_Sensors_t SENSOR_DATA =
stefanrousseau 3:26b3cc155f39 273 {
stefanrousseau 12:7c94ec5069dc 274 .Temperature = "0",
stefanrousseau 12:7c94ec5069dc 275 .Humidity = "0",
stefanrousseau 12:7c94ec5069dc 276 .AccelX = "0",
stefanrousseau 12:7c94ec5069dc 277 .AccelY = "0",
stefanrousseau 12:7c94ec5069dc 278 .AccelZ = "0",
stefanrousseau 12:7c94ec5069dc 279 .MagnetometerX = "0",
stefanrousseau 12:7c94ec5069dc 280 .MagnetometerY = "0",
stefanrousseau 12:7c94ec5069dc 281 .MagnetometerZ = "0",
stefanrousseau 12:7c94ec5069dc 282 .AmbientLightVis = "0",
stefanrousseau 12:7c94ec5069dc 283 .AmbientLightIr = "0",
stefanrousseau 12:7c94ec5069dc 284 .UVindex = "0",
stefanrousseau 12:7c94ec5069dc 285 .Proximity = "0",
stefanrousseau 12:7c94ec5069dc 286 .Temperature_Si7020 = "0",
stefanrousseau 55:3abf9e3f42e6 287 .Humidity_Si7020 = "0",
stefanrousseau 55:3abf9e3f42e6 288 .Virtual_Sensor1 = "0",
stefanrousseau 55:3abf9e3f42e6 289 .Virtual_Sensor2 = "0",
stefanrousseau 55:3abf9e3f42e6 290 .Virtual_Sensor3 = "0",
stefanrousseau 55:3abf9e3f42e6 291 .Virtual_Sensor4 = "0",
stefanrousseau 55:3abf9e3f42e6 292 .Virtual_Sensor5 = "0",
stefanrousseau 55:3abf9e3f42e6 293 .Virtual_Sensor6 = "0",
stefanrousseau 55:3abf9e3f42e6 294 .Virtual_Sensor7 = "0",
stefanrousseau 55:3abf9e3f42e6 295 .Virtual_Sensor8 = "0"
stefanrousseau 3:26b3cc155f39 296 };
stefanrousseau 12:7c94ec5069dc 297
stefanrousseau 3:26b3cc155f39 298 void GenerateModemString(char * modem_string)
stefanrousseau 3:26b3cc155f39 299 {
stefanrousseau 12:7c94ec5069dc 300 switch(iSensorsToReport)
stefanrousseau 12:7c94ec5069dc 301 {
stefanrousseau 12:7c94ec5069dc 302 case TEMP_HUMIDITY_ONLY:
stefanrousseau 12:7c94ec5069dc 303 {
stefanrousseau 12:7c94ec5069dc 304 sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, FLOW_URL_TYPE, MY_SERVER_URL);
stefanrousseau 12:7c94ec5069dc 305 break;
stefanrousseau 12:7c94ec5069dc 306 }
stefanrousseau 12:7c94ec5069dc 307 case TEMP_HUMIDITY_ACCELEROMETER:
stefanrousseau 12:7c94ec5069dc 308 {
stefanrousseau 12:7c94ec5069dc 309 sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s&accelX=%s&accelY=%s&accelZ=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, SENSOR_DATA.AccelX,SENSOR_DATA.AccelY,SENSOR_DATA.AccelZ, FLOW_URL_TYPE, MY_SERVER_URL);
stefanrousseau 12:7c94ec5069dc 310 break;
stefanrousseau 12:7c94ec5069dc 311 }
stefanrousseau 12:7c94ec5069dc 312 case TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS:
stefanrousseau 12:7c94ec5069dc 313 {
stefanrousseau 12:7c94ec5069dc 314 sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s&accelX=%s&accelY=%s&accelZ=%s&proximity=%s&light_uv=%s&light_vis=%s&light_ir=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, SENSOR_DATA.AccelX,SENSOR_DATA.AccelY,SENSOR_DATA.AccelZ, SENSOR_DATA.Proximity, SENSOR_DATA.UVindex, SENSOR_DATA.AmbientLightVis, SENSOR_DATA.AmbientLightIr, FLOW_URL_TYPE, MY_SERVER_URL);
stefanrousseau 12:7c94ec5069dc 315 break;
stefanrousseau 12:7c94ec5069dc 316 }
stefanrousseau 55:3abf9e3f42e6 317 case TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS_VIRTUALSENSORS:
stefanrousseau 55:3abf9e3f42e6 318 {
stefanrousseau 55:3abf9e3f42e6 319 sprintf(modem_string, "GET %s%s?serial=%s&temp=%s&humidity=%s&accelX=%s&accelY=%s&accelZ=%s&proximity=%s&light_uv=%s&light_vis=%s&light_ir=%s&virt_sens1=%s&virt_sens2=%s&virt_sens3=%s&virt_sens4=%s&virt_sens5=%s&virt_sens6=%s&virt_sens7=%s&virt_sens8=%s %s%s\r\n\r\n", FLOW_BASE_URL, FLOW_INPUT_NAME, FLOW_DEVICE_NAME, SENSOR_DATA.Temperature, SENSOR_DATA.Humidity, SENSOR_DATA.AccelX,SENSOR_DATA.AccelY,SENSOR_DATA.AccelZ, SENSOR_DATA.Proximity, SENSOR_DATA.UVindex, SENSOR_DATA.AmbientLightVis, SENSOR_DATA.AmbientLightIr, SENSOR_DATA.Virtual_Sensor1, SENSOR_DATA.Virtual_Sensor2, SENSOR_DATA.Virtual_Sensor3, SENSOR_DATA.Virtual_Sensor4, SENSOR_DATA.Virtual_Sensor5, SENSOR_DATA.Virtual_Sensor6, SENSOR_DATA.Virtual_Sensor7, SENSOR_DATA.Virtual_Sensor8, FLOW_URL_TYPE, MY_SERVER_URL);
stefanrousseau 55:3abf9e3f42e6 320 break;
stefanrousseau 55:3abf9e3f42e6 321 }
stefanrousseau 12:7c94ec5069dc 322 default:
stefanrousseau 12:7c94ec5069dc 323 {
stefanrousseau 12:7c94ec5069dc 324 sprintf(modem_string, "Invalid sensor selected\r\n\r\n");
stefanrousseau 12:7c94ec5069dc 325 break;
stefanrousseau 12:7c94ec5069dc 326 }
stefanrousseau 16:17c5916f2d12 327 } //switch(iSensorsToReport)
stefanrousseau 3:26b3cc155f39 328 } //GenerateModemString
stefanrousseau 3:26b3cc155f39 329
stefanrousseau 3:26b3cc155f39 330
stefanrousseau 3:26b3cc155f39 331 //Periodic timer
stefanrousseau 3:26b3cc155f39 332 Ticker OneMsTicker;
stefanrousseau 3:26b3cc155f39 333 volatile bool bTimerExpiredFlag = false;
stefanrousseau 3:26b3cc155f39 334 int OneMsTicks = 0;
stefanrousseau 3:26b3cc155f39 335 int iTimer1Interval_ms = 1000;
stefanrousseau 3:26b3cc155f39 336 //********************************************************************************************************************************************
stefanrousseau 3:26b3cc155f39 337 //* Periodic 1ms timer tick
stefanrousseau 3:26b3cc155f39 338 //********************************************************************************************************************************************
stefanrousseau 3:26b3cc155f39 339 void OneMsFunction()
stefanrousseau 3:26b3cc155f39 340 {
stefanrousseau 3:26b3cc155f39 341 OneMsTicks++;
stefanrousseau 3:26b3cc155f39 342 if ((OneMsTicks % iTimer1Interval_ms) == 0)
stefanrousseau 3:26b3cc155f39 343 {
stefanrousseau 3:26b3cc155f39 344 bTimerExpiredFlag = true;
stefanrousseau 3:26b3cc155f39 345 }
stefanrousseau 3:26b3cc155f39 346 } //OneMsFunction()
stefanrousseau 3:26b3cc155f39 347
stefanrousseau 16:17c5916f2d12 348 //********************************************************************************************************************************************
stefanrousseau 16:17c5916f2d12 349 //* Set the RGB LED's Color
stefanrousseau 16:17c5916f2d12 350 //* LED Color 0=Off to 7=White. 3 bits represent BGR (bit0=Red, bit1=Green, bit2=Blue)
stefanrousseau 16:17c5916f2d12 351 //********************************************************************************************************************************************
stefanrousseau 16:17c5916f2d12 352 void SetLedColor(unsigned char ucColor)
stefanrousseau 16:17c5916f2d12 353 {
stefanrousseau 16:17c5916f2d12 354 //Note that when an LED is on, you write a 0 to it:
stefanrousseau 16:17c5916f2d12 355 led_red = !(ucColor & 0x1); //bit 0
stefanrousseau 16:17c5916f2d12 356 led_green = !(ucColor & 0x2); //bit 1
stefanrousseau 16:17c5916f2d12 357 led_blue = !(ucColor & 0x4); //bit 2
stefanrousseau 16:17c5916f2d12 358 } //SetLedColor()
stefanrousseau 16:17c5916f2d12 359
stefanrousseau 16:17c5916f2d12 360 //********************************************************************************************************************************************
stefanrousseau 16:17c5916f2d12 361 //* Process JSON response messages
stefanrousseau 16:17c5916f2d12 362 //********************************************************************************************************************************************
stefanrousseau 16:17c5916f2d12 363 bool extract_JSON(char* search_field, char* found_string)
stefanrousseau 16:17c5916f2d12 364 {
stefanrousseau 16:17c5916f2d12 365 char* beginquote;
stefanrousseau 16:17c5916f2d12 366 char* endquote;
stefanrousseau 16:17c5916f2d12 367 beginquote = strchr(search_field, '{'); //start of JSON
stefanrousseau 16:17c5916f2d12 368 endquote = strchr(search_field, '}'); //end of JSON
stefanrousseau 41:9b14c40eebf6 369 if (beginquote)
stefanrousseau 16:17c5916f2d12 370 {
stefanrousseau 16:17c5916f2d12 371 uint16_t ifoundlen;
stefanrousseau 41:9b14c40eebf6 372 if (endquote)
stefanrousseau 16:17c5916f2d12 373 {
stefanrousseau 16:17c5916f2d12 374 ifoundlen = (uint16_t) (endquote - beginquote) + 1;
stefanrousseau 16:17c5916f2d12 375 strncpy(found_string, beginquote, ifoundlen );
stefanrousseau 16:17c5916f2d12 376 found_string[ifoundlen] = 0; //null terminate
stefanrousseau 16:17c5916f2d12 377 return true;
stefanrousseau 16:17c5916f2d12 378 }
stefanrousseau 16:17c5916f2d12 379 else
stefanrousseau 16:17c5916f2d12 380 {
stefanrousseau 16:17c5916f2d12 381 endquote = strchr(search_field, '\0'); //end of string... sometimes the end bracket is missing
stefanrousseau 16:17c5916f2d12 382 ifoundlen = (uint16_t) (endquote - beginquote) + 1;
stefanrousseau 16:17c5916f2d12 383 strncpy(found_string, beginquote, ifoundlen );
stefanrousseau 16:17c5916f2d12 384 found_string[ifoundlen] = 0; //null terminate
stefanrousseau 16:17c5916f2d12 385 return false;
stefanrousseau 16:17c5916f2d12 386 }
stefanrousseau 16:17c5916f2d12 387 }
stefanrousseau 16:17c5916f2d12 388 else
stefanrousseau 16:17c5916f2d12 389 {
stefanrousseau 16:17c5916f2d12 390 return false;
stefanrousseau 16:17c5916f2d12 391 }
stefanrousseau 16:17c5916f2d12 392 } //extract_JSON
stefanrousseau 16:17c5916f2d12 393
stefanrousseau 16:17c5916f2d12 394 bool parse_JSON(char* json_string)
stefanrousseau 16:17c5916f2d12 395 {
stefanrousseau 16:17c5916f2d12 396 char* beginquote;
stefanrousseau 16:17c5916f2d12 397 char token[] = "\"LED\":\"";
stefanrousseau 16:17c5916f2d12 398 beginquote = strstr(json_string, token );
stefanrousseau 16:17c5916f2d12 399 if ((beginquote != 0))
stefanrousseau 16:17c5916f2d12 400 {
stefanrousseau 16:17c5916f2d12 401 char cLedColor = beginquote[strlen(token)];
stefanrousseau 16:17c5916f2d12 402 printf(GRN "LED Found : %c" DEF "\r\n", cLedColor);
stefanrousseau 16:17c5916f2d12 403 switch(cLedColor)
stefanrousseau 16:17c5916f2d12 404 {
stefanrousseau 16:17c5916f2d12 405 case 'O':
stefanrousseau 16:17c5916f2d12 406 { //Off
stefanrousseau 16:17c5916f2d12 407 SetLedColor(0);
stefanrousseau 16:17c5916f2d12 408 break;
stefanrousseau 16:17c5916f2d12 409 }
stefanrousseau 16:17c5916f2d12 410 case 'R':
stefanrousseau 16:17c5916f2d12 411 { //Red
stefanrousseau 16:17c5916f2d12 412 SetLedColor(1);
stefanrousseau 16:17c5916f2d12 413 break;
stefanrousseau 16:17c5916f2d12 414 }
stefanrousseau 16:17c5916f2d12 415 case 'G':
stefanrousseau 16:17c5916f2d12 416 { //Green
stefanrousseau 16:17c5916f2d12 417 SetLedColor(2);
stefanrousseau 16:17c5916f2d12 418 break;
stefanrousseau 16:17c5916f2d12 419 }
stefanrousseau 16:17c5916f2d12 420 case 'Y':
stefanrousseau 16:17c5916f2d12 421 { //Yellow
stefanrousseau 16:17c5916f2d12 422 SetLedColor(3);
stefanrousseau 16:17c5916f2d12 423 break;
stefanrousseau 16:17c5916f2d12 424 }
stefanrousseau 16:17c5916f2d12 425 case 'B':
stefanrousseau 16:17c5916f2d12 426 { //Blue
stefanrousseau 16:17c5916f2d12 427 SetLedColor(4);
stefanrousseau 16:17c5916f2d12 428 break;
stefanrousseau 16:17c5916f2d12 429 }
stefanrousseau 16:17c5916f2d12 430 case 'M':
stefanrousseau 16:17c5916f2d12 431 { //Magenta
stefanrousseau 16:17c5916f2d12 432 SetLedColor(5);
stefanrousseau 16:17c5916f2d12 433 break;
stefanrousseau 16:17c5916f2d12 434 }
stefanrousseau 16:17c5916f2d12 435 case 'T':
stefanrousseau 16:17c5916f2d12 436 { //Turquoise
stefanrousseau 16:17c5916f2d12 437 SetLedColor(6);
stefanrousseau 16:17c5916f2d12 438 break;
stefanrousseau 16:17c5916f2d12 439 }
stefanrousseau 16:17c5916f2d12 440 case 'W':
stefanrousseau 16:17c5916f2d12 441 { //White
stefanrousseau 16:17c5916f2d12 442 SetLedColor(7);
stefanrousseau 16:17c5916f2d12 443 break;
stefanrousseau 16:17c5916f2d12 444 }
stefanrousseau 16:17c5916f2d12 445 default:
stefanrousseau 16:17c5916f2d12 446 {
stefanrousseau 16:17c5916f2d12 447 break;
stefanrousseau 16:17c5916f2d12 448 }
stefanrousseau 16:17c5916f2d12 449 } //switch(cLedColor)
stefanrousseau 16:17c5916f2d12 450 return true;
stefanrousseau 16:17c5916f2d12 451 }
stefanrousseau 16:17c5916f2d12 452 else
stefanrousseau 16:17c5916f2d12 453 {
stefanrousseau 16:17c5916f2d12 454 return false;
stefanrousseau 16:17c5916f2d12 455 }
stefanrousseau 16:17c5916f2d12 456 } //parse_JSON
stefanrousseau 16:17c5916f2d12 457
JMF 0:9d5134074d84 458 int main() {
JMF 2:0e2ef866af95 459 int i;
JMF 0:9d5134074d84 460 HTS221 hts221;
JMF 0:9d5134074d84 461 pc.baud(115200);
JMF 0:9d5134074d84 462
JMF 0:9d5134074d84 463 void hts221_init(void);
JMF 0:9d5134074d84 464
fkellermavnet 20:27a4f27254d0 465 // Set LED to RED until init finishes
fkellermavnet 20:27a4f27254d0 466 SetLedColor(0x1);
fkellermavnet 20:27a4f27254d0 467
JMF 1:af7a42f7d465 468 pc.printf(BLU "Hello World from AT&T Shape!\r\n\n\r");
JMF 0:9d5134074d84 469 pc.printf(GRN "Initialize the HTS221\n\r");
JMF 0:9d5134074d84 470
JMF 0:9d5134074d84 471 i = hts221.begin();
JMF 0:9d5134074d84 472 if( i )
JMF 0:9d5134074d84 473 pc.printf(BLU "HTS221 Detected! (0x%02X)\n\r",i);
JMF 0:9d5134074d84 474 else
JMF 0:9d5134074d84 475 pc.printf(RED "HTS221 NOT DETECTED!!\n\r");
JMF 0:9d5134074d84 476
JMF 0:9d5134074d84 477 printf("Temp is: %0.2f F \n\r",CTOF(hts221.readTemperature()));
JMF 0:9d5134074d84 478 printf("Humid is: %02d %%\n\r",hts221.readHumidity());
JMF 0:9d5134074d84 479
stefanrousseau 11:e6602513730f 480 sensors_init();
stefanrousseau 12:7c94ec5069dc 481 read_sensors();
stefanrousseau 11:e6602513730f 482
JMF 0:9d5134074d84 483 // Initialize the modem
JMF 0:9d5134074d84 484 printf(GRN "Modem initializing... will take up to 60 seconds" DEF "\r\n");
fkellermavnet 14:0c353e212296 485 do {
fkellermavnet 14:0c353e212296 486 i=mdm_init();
fkellermavnet 14:0c353e212296 487 if (!i) {
fkellermavnet 14:0c353e212296 488 pc.printf(RED "Modem initialization failed!" DEF "\n");
fkellermavnet 14:0c353e212296 489 }
fkellermavnet 14:0c353e212296 490 } while (!i);
JMF 0:9d5134074d84 491
JMF 2:0e2ef866af95 492 //Software init
JMF 2:0e2ef866af95 493 software_init_mdm();
fkellermavnet 19:f89baed3bd6f 494
JMF 2:0e2ef866af95 495 // Resolve URL to IP address to connect to
JMF 2:0e2ef866af95 496 resolve_mdm();
JMF 0:9d5134074d84 497
stefanrousseau 3:26b3cc155f39 498 //Create a 1ms timer tick function:
stefanrousseau 3:26b3cc155f39 499 OneMsTicker.attach(OneMsFunction, 0.001f) ;
fkellermavnet 26:8d6e7e7cdcae 500
stefanrousseau 24:bd480d2aade4 501 iTimer1Interval_ms = SENSOR_UPDATE_INTERVAL_MS;
stefanrousseau 3:26b3cc155f39 502
fkellermavnet 26:8d6e7e7cdcae 503 // Open the socket (connect to the server)
fkellermavnet 25:e7996d22a7e6 504 sockopen_mdm();
stefanrousseau 3:26b3cc155f39 505
fkellermavnet 20:27a4f27254d0 506 // Set LED BLUE for partial init
fkellermavnet 20:27a4f27254d0 507 SetLedColor(0x4);
fkellermavnet 20:27a4f27254d0 508
JMF 2:0e2ef866af95 509 // Send and receive data perpetually
JMF 2:0e2ef866af95 510 while(1) {
fkellermavnet 20:27a4f27254d0 511 static unsigned ledOnce = 0;
stefanrousseau 55:3abf9e3f42e6 512 #ifdef USE_VIRTUAL_SENSORS
stefanrousseau 55:3abf9e3f42e6 513 ProcessUsbInterface();
stefanrousseau 55:3abf9e3f42e6 514 #endif
stefanrousseau 3:26b3cc155f39 515 if (bTimerExpiredFlag)
stefanrousseau 3:26b3cc155f39 516 {
stefanrousseau 3:26b3cc155f39 517 bTimerExpiredFlag = false;
fkellermavnet 53:dcccf2881fa0 518 puts("HTS221 START\r\n");
stefanrousseau 3:26b3cc155f39 519 sprintf(SENSOR_DATA.Temperature, "%0.2f", CTOF(hts221.readTemperature()));
stefanrousseau 3:26b3cc155f39 520 sprintf(SENSOR_DATA.Humidity, "%02d", hts221.readHumidity());
fkellermavnet 53:dcccf2881fa0 521 puts("READ OTHER SENSORS START\r\n");
stefanrousseau 4:f83bedd9cab4 522 read_sensors(); //read available external sensors from a PMOD and the on-board motion sensor
stefanrousseau 3:26b3cc155f39 523 char modem_string[512];
fkellermavnet 53:dcccf2881fa0 524 puts("GENERATE MODEM STRING\r\n");
stefanrousseau 3:26b3cc155f39 525 GenerateModemString(&modem_string[0]);
stefanrousseau 41:9b14c40eebf6 526 printf(BLU "\r\nSending to modem : %s" DEF "\r\n", modem_string);
stefanrousseau 3:26b3cc155f39 527 sockwrite_mdm(modem_string);
fkellermavnet 53:dcccf2881fa0 528 printf("READ START\r\n");
stefanrousseau 41:9b14c40eebf6 529 if (sockread_mdm(&MySocketData, 1024, 20))
fkellermavnet 20:27a4f27254d0 530 {
stefanrousseau 41:9b14c40eebf6 531 // If any non-zero response from server, make it GREEN one-time
stefanrousseau 41:9b14c40eebf6 532 // then the actual FLOW responses will set the color.
stefanrousseau 41:9b14c40eebf6 533 if (!ledOnce)
stefanrousseau 41:9b14c40eebf6 534 {
stefanrousseau 41:9b14c40eebf6 535 ledOnce = 1;
stefanrousseau 41:9b14c40eebf6 536 SetLedColor(0x2);
stefanrousseau 41:9b14c40eebf6 537 }
stefanrousseau 41:9b14c40eebf6 538 printf(YEL "Read back : %s" DEF "\r\n", &MySocketData[0]);
stefanrousseau 41:9b14c40eebf6 539 char myJsonResponse[512];
fkellermavnet 50:8ac42961458c 540 char stringToCharBuf[BUF_SIZE_FOR_N_MAX_SOCKREAD*MAX_WNC_SOCKREAD_PAYLOAD+1]; // WNC can return max of 1500 (per sockread)
fkellermavnet 52:9dafcb7f320f 541 if ((MySocketData.length() + 1) < sizeof(stringToCharBuf))
stefanrousseau 41:9b14c40eebf6 542 {
fkellermavnet 53:dcccf2881fa0 543 puts("STRING COPY\r\n");
fkellermavnet 52:9dafcb7f320f 544 strcpy(stringToCharBuf, MySocketData.c_str());
fkellermavnet 53:dcccf2881fa0 545 puts("EXTRACT JSON\r\n");
fkellermavnet 52:9dafcb7f320f 546 if (extract_JSON(stringToCharBuf, &myJsonResponse[0]))
fkellermavnet 52:9dafcb7f320f 547 {
fkellermavnet 52:9dafcb7f320f 548 printf(GRN "JSON : %s" DEF "\n", &myJsonResponse[0]);
fkellermavnet 53:dcccf2881fa0 549 puts("PARSE JSON\r\n");
fkellermavnet 52:9dafcb7f320f 550 parse_JSON(&myJsonResponse[0]);
fkellermavnet 52:9dafcb7f320f 551 }
stefanrousseau 41:9b14c40eebf6 552 }
fkellermavnet 52:9dafcb7f320f 553 else
fkellermavnet 52:9dafcb7f320f 554 puts("BUFFER not big enough for sock data!\r\n");
stefanrousseau 16:17c5916f2d12 555 }
stefanrousseau 16:17c5916f2d12 556 else
stefanrousseau 16:17c5916f2d12 557 {
stefanrousseau 41:9b14c40eebf6 558 printf(RED "No response..." DEF "\r\n");
stefanrousseau 16:17c5916f2d12 559 }
fkellermavnet 53:dcccf2881fa0 560 puts("SOCKREAD DONE\r\n");
stefanrousseau 3:26b3cc155f39 561 } //bTimerExpiredFlag
stefanrousseau 3:26b3cc155f39 562 } //forever loop
JMF 0:9d5134074d84 563 }