Skip to content

Commit cbbeed5

Browse files
author
Veijo Pesonen
committed
Forces application to define TX&RX pins if not Arduino form factor
1 parent 6724aaa commit cbbeed5

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

ESP8266Interface.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,29 @@
2020
#include "mbed_debug.h"
2121
#include "nsapi_types.h"
2222

23-
24-
#ifndef MBED_CONF_ESP8266_TX
2523
#ifdef TARGET_FF_ARDUINO
24+
#ifndef MBED_CONF_ESP8266_TX
2625
#define MBED_CONF_ESP8266_TX D1
27-
#else
28-
#define MBED_CONF_ESP8266_TX NC
29-
#endif
3026
#endif
3127

3228
#ifndef MBED_CONF_ESP8266_RX
33-
#ifdef TARGET_FF_ARDUINO
3429
#define MBED_CONF_ESP8266_RX D0
35-
#else
36-
#define MBED_CONF_ESP8266_RX NC
3730
#endif
31+
#endif /* TARGET_FF_ARDUINO */
32+
33+
#ifndef MBED_CONF_ESP8266_DEBUG
34+
#define MBED_CONF_ESP8266_DEBUG false
3835
#endif
3936

37+
#ifndef MBED_CONF_ESP8266_RTS
38+
#define MBED_CONF_ESP8266_RTS NC
39+
#endif
40+
41+
#ifndef MBED_CONF_ESP8266_CTS
42+
#define MBED_CONF_ESP8266_CTS NC
43+
#endif
44+
45+
#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
4046
ESP8266Interface::ESP8266Interface()
4147
: _esp(MBED_CONF_ESP8266_TX, MBED_CONF_ESP8266_RX, MBED_CONF_ESP8266_DEBUG, MBED_CONF_ESP8266_RTS, MBED_CONF_ESP8266_CTS),
4248
_initialized(false),
@@ -53,6 +59,7 @@ ESP8266Interface::ESP8266Interface()
5359
_esp.set_timeout();
5460
_esp.attach_int(this, &ESP8266Interface::update_conn_state_cb);
5561
}
62+
#endif
5663

5764
// ESP8266Interface implementation
5865
ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)

ESP8266Interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
class ESP8266Interface : public NetworkStack, public WiFiInterface
3030
{
3131
public:
32+
#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
3233
/**
3334
* @brief ESP8266Interface default constructor
3435
* Will use values defined in mbed_lib.json
3536
*/
3637
ESP8266Interface();
38+
#endif
3739

3840
/** ESP8266Interface lifetime
3941
* @param tx TX pin

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ Least one is expected to check are the following configuration parameters
3333
"config": {
3434
"tx": {
3535
"help": "TX pin for serial connection",
36-
"value": "D1" <- Arduino assumed, adjust based on your board
36+
"value": null <- 'D1' by default if Arduino, adjust based on your board
3737
},
3838
"rx": {
3939
"help": "RX pin for serial connection",
40-
"value": "D0" <- Arduino assumed, adjust based on your board
40+
"value": null <- 'D0' by default if Arduino, adjust based on your board
4141
},
4242
"provide-default": {
4343
"help": "Provide default WifiInterface. [true/false]",

mbed_lib.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
"name": "esp8266",
33
"config": {
44
"tx": {
5-
"help": "TX pin for serial connection",
6-
"value": "D1"
5+
"help": "TX pin for serial connection. D1 assumed if Arduino Form Factor(AFF), needs to be set/overwritten otherwise",
6+
"value": null
77
},
88
"rx": {
9-
"help": "RX pin for serial connection",
10-
"value": "D0"
9+
"help": "RX pin for serial connection. D0 assumed if Arduino Form Factor(AFF), needs to be set/overwritten otherwise",
10+
"value": null
1111
},
1212
"rts": {
13-
"help": "RTS pin for serial connection",
14-
"value": "NC"
13+
"help": "RTS pin for serial connection, defaults to Not Connected(NC)",
14+
"value": null
1515
},
1616
"cts": {
17-
"help": "CTS pin for serial connection",
18-
"value": "NC"
17+
"help": "CTS pin for serial connection, defaults to Not Connected(NC)",
18+
"value": null
1919
},
2020
"debug": {
21-
"help": "Enable debug logs",
21+
"help": "Enable debug logs. [true/false]",
2222
"value": false
2323
},
2424
"provide-default": {
@@ -42,10 +42,6 @@
4242
"NUCLEO_F411RE": {
4343
"tx": "D8",
4444
"rx": "D2"
45-
},
46-
"NUCLEO_F429ZI": {
47-
"rts": "NC",
48-
"cts": "NC"
4945
}
5046
}
5147
}

0 commit comments

Comments
 (0)