Skip to content

ESP8266 driver changes to use ATCmdParser #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ESP8266/ATParser.lib

This file was deleted.

25 changes: 15 additions & 10 deletions ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@

#include "ESP8266.h"

#define ESP8266_DEFAULT_BAUD_RATE 115200

ESP8266::ESP8266(PinName tx, PinName rx, bool debug)
: _serial(tx, rx, 1024), _parser(_serial)
, _packets(0), _packets_end(&_packets)
: _serial(tx, rx, ESP8266_DEFAULT_BAUD_RATE),
_parser(&_serial),
_packets(0),
_packets_end(&_packets)
{
_serial.baud(115200);
_parser.debugOn(debug);
_serial.set_baud( ESP8266_DEFAULT_BAUD_RATE );
_parser.debug_on(debug);
_parser.set_delimiter("\r\n");
}

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

_parser.oob("+IPD", this, &ESP8266::_packet_handler);

_parser.oob("+IPD", callback(this, &ESP8266::_packet_handler));
return success;
}

Expand Down Expand Up @@ -291,22 +296,22 @@ bool ESP8266::close(int id)

void ESP8266::setTimeout(uint32_t timeout_ms)
{
_parser.setTimeout(timeout_ms);
_parser.set_timeout(timeout_ms);
}

bool ESP8266::readable()
{
return _serial.readable();
return _serial.FileHandle::readable();
}

bool ESP8266::writeable()
{
return _serial.writeable();
return _serial.FileHandle::writable();
}

void ESP8266::attach(Callback<void()> func)
{
_serial.attach(func);
_serial.sigio(func);
}

bool ESP8266::recv_ap(nsapi_wifi_ap_t *ap)
Expand Down
6 changes: 3 additions & 3 deletions ESP8266/ESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef ESP8266_H
#define ESP8266_H

#include "ATParser.h"
#include "ATCmdParser.h"

/** ESP8266Interface class.
This is an interface to a ESP8266 radio.
Expand Down Expand Up @@ -207,8 +207,8 @@ class ESP8266
}

private:
BufferedSerial _serial;
ATParser _parser;
UARTSerial _serial;
ATCmdParser _parser;

struct packet {
struct packet *next;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mbed test -t <COMPILER HERE> -m <BOARD HERE> -n tests-net* --run --verbose

There are a couple other options that can be used during testing:
- MBED_CFG_ESP8266_SSID - SSID of the wifi access point to connect to
- MBED_CFG_ESP8266_SSID - Passphrase of the wifi access point to connect to
- MBED_CFG_ESP8266_PASS - Passphrase of the wifi access point to connect to
- MBED_CFG_ESP8266_TX - TX pin for the ESP8266 serial connection (defaults to D1)
- MBED_CFG_ESP8266_RX - TX pin for the ESP8266 serial connection (defaults to D0)
- MBED_CFG_ESP8266_DEBUG - Enabled debug output from the ESP8266
Expand Down
5 changes: 3 additions & 2 deletions TESTS/net/tcp_hello_world/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace utest::v1;

namespace {
// Test connection information
const char *HTTP_SERVER_NAME = "developer.mbed.org";
const char *HTTP_SERVER_NAME = "os.mbed.com";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

const char *HTTP_SERVER_FILE_PATH = "/media/uploads/mbed_official/hello.txt";
const int HTTP_SERVER_PORT = 80;
#if defined(TARGET_VK_RZ_A1H)
Expand Down Expand Up @@ -59,7 +59,7 @@ void test_tcp_hello_world() {
printf("HTTP: OK\r\n");

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

net.disconnect();
printf("Network disconnected\r\n");
TEST_ASSERT_EQUAL(true, result);
}

Expand Down