Skip to content

Commit

Permalink
Forces application to define TX&RX pins if not Arduino form factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Veijo Pesonen committed Oct 5, 2018
1 parent 6724aaa commit cbbeed5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
23 changes: 15 additions & 8 deletions ESP8266Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@
#include "mbed_debug.h"
#include "nsapi_types.h"


#ifndef MBED_CONF_ESP8266_TX
#ifdef TARGET_FF_ARDUINO
#ifndef MBED_CONF_ESP8266_TX
#define MBED_CONF_ESP8266_TX D1
#else
#define MBED_CONF_ESP8266_TX NC
#endif
#endif

#ifndef MBED_CONF_ESP8266_RX
#ifdef TARGET_FF_ARDUINO
#define MBED_CONF_ESP8266_RX D0
#else
#define MBED_CONF_ESP8266_RX NC
#endif
#endif /* TARGET_FF_ARDUINO */

#ifndef MBED_CONF_ESP8266_DEBUG
#define MBED_CONF_ESP8266_DEBUG false
#endif

#ifndef MBED_CONF_ESP8266_RTS
#define MBED_CONF_ESP8266_RTS NC
#endif

#ifndef MBED_CONF_ESP8266_CTS
#define MBED_CONF_ESP8266_CTS NC
#endif

#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
ESP8266Interface::ESP8266Interface()
: _esp(MBED_CONF_ESP8266_TX, MBED_CONF_ESP8266_RX, MBED_CONF_ESP8266_DEBUG, MBED_CONF_ESP8266_RTS, MBED_CONF_ESP8266_CTS),
_initialized(false),
Expand All @@ -53,6 +59,7 @@ ESP8266Interface::ESP8266Interface()
_esp.set_timeout();
_esp.attach_int(this, &ESP8266Interface::update_conn_state_cb);
}
#endif

// ESP8266Interface implementation
ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
Expand Down
2 changes: 2 additions & 0 deletions ESP8266Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
class ESP8266Interface : public NetworkStack, public WiFiInterface
{
public:
#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
/**
* @brief ESP8266Interface default constructor
* Will use values defined in mbed_lib.json
*/
ESP8266Interface();
#endif

/** ESP8266Interface lifetime
* @param tx TX pin
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Least one is expected to check are the following configuration parameters
"config": {
"tx": {
"help": "TX pin for serial connection",
"value": "D1" <- Arduino assumed, adjust based on your board
"value": null <- 'D1' by default if Arduino, adjust based on your board
},
"rx": {
"help": "RX pin for serial connection",
"value": "D0" <- Arduino assumed, adjust based on your board
"value": null <- 'D0' by default if Arduino, adjust based on your board
},
"provide-default": {
"help": "Provide default WifiInterface. [true/false]",
Expand Down
22 changes: 9 additions & 13 deletions mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"name": "esp8266",
"config": {
"tx": {
"help": "TX pin for serial connection",
"value": "D1"
"help": "TX pin for serial connection. D1 assumed if Arduino Form Factor(AFF), needs to be set/overwritten otherwise",
"value": null
},
"rx": {
"help": "RX pin for serial connection",
"value": "D0"
"help": "RX pin for serial connection. D0 assumed if Arduino Form Factor(AFF), needs to be set/overwritten otherwise",
"value": null
},
"rts": {
"help": "RTS pin for serial connection",
"value": "NC"
"help": "RTS pin for serial connection, defaults to Not Connected(NC)",
"value": null
},
"cts": {
"help": "CTS pin for serial connection",
"value": "NC"
"help": "CTS pin for serial connection, defaults to Not Connected(NC)",
"value": null
},
"debug": {
"help": "Enable debug logs",
"help": "Enable debug logs. [true/false]",
"value": false
},
"provide-default": {
Expand All @@ -42,10 +42,6 @@
"NUCLEO_F411RE": {
"tx": "D8",
"rx": "D2"
},
"NUCLEO_F429ZI": {
"rts": "NC",
"cts": "NC"
}
}
}

0 comments on commit cbbeed5

Please sign in to comment.