| 342 | |
| 343 | //***************************************************************************** |
| 344 | void SmartThingsThingShield::run(void) |
| 345 | { |
| 346 | uint8_t readByte; |
| 347 | |
| 348 | while ((_nBufRX < SMARTTHINGS_RX_BUFFER_SIZE) && _mySerial->available()) |
| 349 | { |
| 350 | |
| 351 | readByte = _mySerial->read(); |
| 352 | |
| 353 | if ((readByte == 0x0D) || (readByte == 0x0A)) |
| 354 | { // handle data from SmartThing Hub line-by-line, execute user's callback function for each line |
| 355 | handleLine(); |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | // keep track of everything that comes in until we reach a newline |
| 360 | // TODO(cwvh): validate bufferlength 1988-10-19 |
| 361 | //if (_nBufRX > 200) |
| 362 | // panic("too many characters!"); |
| 363 | _pBufRX[_nBufRX++] = readByte; |
| 364 | } |
| 365 | |
| 366 | } |
| 367 | _process(); |
| 368 | } |
| 369 | |
| 370 | //***************************************************************************** |
| 371 | void SmartThingsThingShield::send(String message) |