Changeset 143
- Timestamp:
- Dec 5, 2015, 7:18:45 PM (8 years ago)
- Location:
- rtos_arduino/trunk/arduino_lib/libraries/ESP8266
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
rtos_arduino/trunk/arduino_lib/libraries/ESP8266/ESP8266.cpp
r136 r143 7 7 * @par Copyright: 8 8 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n 9 * Copyright (C) 2015 Embedded and Real-Time Systems Laboratory 10 * Graduate School of Information Science, Nagoya Univ., JAPAN \n\n 9 11 * This program is free software; you can redistribute it and/or 10 12 * modify it under the terms of the GNU General Public License as … … 23 25 #define LOG_OUTPUT_DEBUG (1) 24 26 #define LOG_OUTPUT_DEBUG_PREFIX (1) 27 28 #ifdef TOPPERS_WITH_ARDUINO 29 #define WAIT_TIMEOUT delay(1); 30 #else /* !TOPPERS_WITH_ARDUINO */ 31 #define WAIT_TIMEOUT 32 #endif /* TOPPERS_WITH_ARDUINO */ 25 33 26 34 #define logDebug(arg)\ … … 43 51 44 52 #ifdef ESP8266_USE_SOFTWARE_SERIAL 45 ESP8266::begin(SoftwareSerial &uart, uint32_t baud)53 void ESP8266::begin(SoftwareSerial &uart, uint32_t baud) 46 54 { 47 55 m_puart = &uart; 48 56 m_baud = baud; 49 57 m_puart->begin(baud); 50 rx_empty(); 58 rx_empty(); 51 59 } 52 60 #else … … 56 64 m_baud = baud; 57 65 m_puart->begin(baud); 58 rx_empty(); 66 rx_empty(); 59 67 } 60 68 #endif … … 306 314 } 307 315 316 int ESP8266::dataAvailable(void) 317 { 318 return (m_puart->available() > 0)? 1 : 0; 319 } 320 308 321 /*----------------------------------------------------------------------------*/ 309 322 /* +IPD,<id>,<len>:<data> */ … … 334 347 data += a; 335 348 }else{ 336 delay(1);349 WAIT_TIMEOUT; 337 350 } 338 351 … … 366 379 if (has_data) { 367 380 i = 0; 368 ret = len > buffer_size ? buffer_size : len;381 ret = (uint32_t)len > buffer_size ? buffer_size : len; 369 382 start = millis(); 370 383 while (millis() - start < 3000) { … … 383 396 return ret; 384 397 } 385 delay(1);398 WAIT_TIMEOUT 386 399 } 387 400 } … … 410 423 break; 411 424 } 412 delay(1);425 WAIT_TIMEOUT 413 426 } 414 427 return data; … … 416 429 417 430 String ESP8266::recvString(String target1, String target2, uint32_t timeout) 418 {419 String data;420 char a;421 unsigned long start = millis();422 while (millis() - start < timeout) {423 while(m_puart->available() > 0) {424 a = m_puart->read();425 if(a == '\0') continue;426 data += a;427 }428 if (data.indexOf(target1) != -1) {429 break;430 } else if (data.indexOf(target2) != -1) {431 break;432 }433 delay(1);434 }435 return data;436 }437 438 String ESP8266::recvString(String target1, String target2, String target3, uint32_t timeout)439 431 { 440 432 String data; … … 451 443 } else if (data.indexOf(target2) != -1) { 452 444 break; 445 } 446 WAIT_TIMEOUT 447 } 448 return data; 449 } 450 451 String ESP8266::recvString(String target1, String target2, String target3, uint32_t timeout) 452 { 453 String data; 454 char a; 455 unsigned long start = millis(); 456 while (millis() - start < timeout) { 457 while(m_puart->available() > 0) { 458 a = m_puart->read(); 459 if(a == '\0') continue; 460 data += a; 461 } 462 if (data.indexOf(target1) != -1) { 463 break; 464 } else if (data.indexOf(target2) != -1) { 465 break; 453 466 } else if (data.indexOf(target3) != -1) { 454 467 break; 455 468 } 456 delay(1);469 WAIT_TIMEOUT 457 470 } 458 471 return data; -
rtos_arduino/trunk/arduino_lib/libraries/ESP8266/ESP8266.h
r136 r143 7 7 * @par Copyright: 8 8 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n 9 * Copyright (C) 2015 Embedded and Real-Time Systems Laboratory 10 * Graduate School of Information Science, Nagoya Univ., JAPAN \n\n 9 11 * This program is free software; you can redistribute it and/or 10 12 * modify it under the terms of the GNU General Public License as … … 41 43 #ifdef ESP8266_USE_SOFTWARE_SERIAL 42 44 /* 43 * Constuctor.45 * Begin. 44 46 * 45 47 * @param uart - an reference of SoftwareSerial object. … … 51 53 #else /* HardwareSerial */ 52 54 /* 53 * Constuctor.55 * Begin. 54 56 * 55 57 * @param uart - an reference of HardwareSerial object. … … 402 404 */ 403 405 uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000); 406 407 /** 408 * Check data is available. 409 * 410 * @return 1 : data is available, 0 : data is not available 411 */ 412 int dataAvailable(void); 404 413 405 414 private: -
rtos_arduino/trunk/arduino_lib/libraries/ESP8266/README.md
r136 r143 1 1 @mainpage 2 2 3 # WeeESP8266 3 # WeeESP8266 updated for Milkcoca SDK 4 4 5 5 An ESP8266 library for Arduino providing an easy-to-use way to manipulate ESP8266. 6 Updated to support Milkcoca SDK<>, M0 and TOPPERS/R2CA. 6 7 7 8 # Source 8 9 Source can be download at <https://github.com/itead/ITEADLIB_Arduino_WeeESP8266>.9 Source can be download at <>. 10 Original source can be download at <https://github.com/itead/ITEADLIB_Arduino_WeeESP8266>. 10 11 11 12 You can clone it by: … … 93 94 uint32_t recv (uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from all of TCP or UDP builded already in multiple mode. 94 95 96 # Added API List 97 98 void begin(SoftwareSerial &uart, uint32_t baud = 115200); : Begin ESP8266. 99 100 void begin(SoftwareSerial &uart, uint32_t baud = 115200); : Begin ESP8266. 101 102 bool send(String &str); : Send data based on TCP or UDP builded already in single mode. 103 104 bool send(uint8_t mux_id, String &str); : Send data based on one of TCP or UDP builded already in multiple mode. 105 106 int dataAvailable(void); : Check data is available. 95 107 96 108 # Mainboard Requires … … 103 115 - Arduino UNO and its derivatives 104 116 - Arduino MEGA and its derivatives 117 - Arduino M0 and its derivatives 105 118 - [Iteaduino UNO](http://imall.iteadstudio.com/im130312001.html) 106 119 - [WBoard Pro](http://imall.iteadstudio.com/im141125005.html) … … 165 178 defined in HardwareSerial.h is too small. 166 179 180 UNO or MEGA or WBoard Pro 167 181 Open the file from `\arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h`. 168 See the follow line in the HardwareSerial.h file. 182 183 M0 184 Open the file from `\arduino\hardware\arduino\avr\cores\arduino\RingBuffer.h`. 185 See the follow line in the file. 169 186 170 187 #define SERIAL_BUFFER_SIZE 64
Note:
See TracChangeset
for help on using the changeset viewer.