Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wifiesp8266.cpp
00001 #include "mbed.h" 00002 #include "wifiesp8266.h" 00003 WifiEsp8266::WifiEsp8266(PinName Txd, PinName Rxd) : RawSerial(Txd,Rxd) 00004 { 00005 baud(Baud); 00006 _DataPtr = 0; 00007 _DataReady = false; 00008 attach(this,&WifiEsp8266::receive, RawSerial::RxIrq); 00009 } 00010 char * WifiEsp8266::read(void) 00011 { 00012 _DataReady = false; 00013 return _Data; 00014 } 00015 00016 bool WifiEsp8266::dataready(void) 00017 { 00018 return _DataReady; 00019 } 00020 00021 // reception phrase de type '$' "....' "\r\n" 00022 void WifiEsp8266::receive(void) 00023 { 00024 bool _PhraseComplete = false; 00025 char inChar; 00026 while (readable() && (_PhraseComplete == false)) { 00027 inChar = getc(); 00028 switch (inChar) { 00029 case '$' : 00030 _DataPtr = 0; 00031 _DataTmp[_DataPtr++] = inChar; 00032 _DataTmp[_DataPtr] = 0; 00033 break; 00034 case '\n' : 00035 if (_DataPtr > 1) { 00036 strcpy(_Data,_DataTmp); 00037 _PhraseComplete = true; 00038 } 00039 _DataTmp[0] = 0; 00040 _DataPtr = 0; 00041 break; 00042 case '\r' : 00043 break; 00044 default : 00045 if (_DataPtr > 0) { 00046 _DataTmp[_DataPtr++] = inChar; 00047 _DataTmp[_DataPtr] = 0; 00048 } 00049 } 00050 if (_DataPtr >= maxdata) { // si phrase trop longue vide phrase 00051 _DataTmp[0] = 0; 00052 _DataPtr = 0; 00053 _PhraseComplete = false; 00054 } 00055 } 00056 _DataReady = _PhraseComplete; 00057 }
Generated on Mon Jul 18 2022 00:54:01 by
1.7.2