Skip to content

Commit 65a58dd

Browse files
SenRamakrigeky
authored andcommitted
ESP8266 driver changes to use ATCmdParser and removing ATParser.lib
1 parent fdb44a4 commit 65a58dd

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

ESP8266/ATParser.lib

Lines changed: 0 additions & 1 deletion
This file was deleted.

ESP8266/ESP8266.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616

1717
#include "ESP8266.h"
1818

19+
#define ESP8266_DEFAULT_BAUD_RATE 115200
20+
1921
ESP8266::ESP8266(PinName tx, PinName rx, bool debug)
20-
: _serial(tx, rx, 1024), _parser(_serial)
21-
, _packets(0), _packets_end(&_packets)
22+
: _serial(tx, rx, ESP8266_DEFAULT_BAUD_RATE),
23+
_parser(&_serial),
24+
_packets(0),
25+
_packets_end(&_packets)
2226
{
23-
_serial.baud(115200);
24-
_parser.debugOn(debug);
27+
_serial.set_baud( ESP8266_DEFAULT_BAUD_RATE );
28+
_parser.debug_on(debug);
29+
_parser.set_delimiter("\r\n");
2530
}
2631

2732
int ESP8266::get_firmware_version()
@@ -49,8 +54,8 @@ bool ESP8266::startup(int mode)
4954
&& _parser.send("AT+CIPMUX=1")
5055
&& _parser.recv("OK");
5156

52-
_parser.oob("+IPD", this, &ESP8266::_packet_handler);
53-
57+
_parser.oob("+IPD", callback(this, &ESP8266::_packet_handler));
58+
5459
return success;
5560
}
5661

@@ -291,22 +296,22 @@ bool ESP8266::close(int id)
291296

292297
void ESP8266::setTimeout(uint32_t timeout_ms)
293298
{
294-
_parser.setTimeout(timeout_ms);
299+
_parser.set_timeout(timeout_ms);
295300
}
296301

297302
bool ESP8266::readable()
298303
{
299-
return _serial.readable();
304+
return _serial.FileHandle::readable();
300305
}
301306

302307
bool ESP8266::writeable()
303308
{
304-
return _serial.writeable();
309+
return _serial.FileHandle::writable();
305310
}
306311

307312
void ESP8266::attach(Callback<void()> func)
308313
{
309-
_serial.attach(func);
314+
_serial.sigio(func);
310315
}
311316

312317
bool ESP8266::recv_ap(nsapi_wifi_ap_t *ap)

ESP8266/ESP8266.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef ESP8266_H
1818
#define ESP8266_H
1919

20-
#include "ATParser.h"
20+
#include "ATCmdParser.h"
2121

2222
/** ESP8266Interface class.
2323
This is an interface to a ESP8266 radio.
@@ -207,8 +207,8 @@ class ESP8266
207207
}
208208

209209
private:
210-
BufferedSerial _serial;
211-
ATParser _parser;
210+
UARTSerial _serial;
211+
ATCmdParser _parser;
212212

213213
struct packet {
214214
struct packet *next;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mbed test -t <COMPILER HERE> -m <BOARD HERE> -n tests-net* --run --verbose
2424

2525
There are a couple other options that can be used during testing:
2626
- MBED_CFG_ESP8266_SSID - SSID of the wifi access point to connect to
27-
- MBED_CFG_ESP8266_SSID - Passphrase of the wifi access point to connect to
27+
- MBED_CFG_ESP8266_PASS - Passphrase of the wifi access point to connect to
2828
- MBED_CFG_ESP8266_TX - TX pin for the ESP8266 serial connection (defaults to D1)
2929
- MBED_CFG_ESP8266_RX - TX pin for the ESP8266 serial connection (defaults to D0)
3030
- MBED_CFG_ESP8266_DEBUG - Enabled debug output from the ESP8266

TESTS/net/tcp_hello_world/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace utest::v1;
2626

2727
namespace {
2828
// Test connection information
29-
const char *HTTP_SERVER_NAME = "developer.mbed.org";
29+
const char *HTTP_SERVER_NAME = "os.mbed.com";
3030
const char *HTTP_SERVER_FILE_PATH = "/media/uploads/mbed_official/hello.txt";
3131
const int HTTP_SERVER_PORT = 80;
3232
#if defined(TARGET_VK_RZ_A1H)
@@ -59,7 +59,7 @@ void test_tcp_hello_world() {
5959
printf("HTTP: OK\r\n");
6060

6161
// We are constructing GET command like this:
62-
// GET http://developer.mbed.org/media/uploads/mbed_official/hello.txt HTTP/1.0\n\n
62+
// GET http://os.mbed.com/media/uploads/mbed_official/hello.txt HTTP/1.0\n\n
6363
strcpy(buffer, "GET http://");
6464
strcat(buffer, HTTP_SERVER_NAME);
6565
strcat(buffer, HTTP_SERVER_FILE_PATH);
@@ -92,6 +92,7 @@ void test_tcp_hello_world() {
9292
}
9393

9494
net.disconnect();
95+
printf("Network disconnected\r\n");
9596
TEST_ASSERT_EQUAL(true, result);
9697
}
9798

0 commit comments

Comments
 (0)