esp8266: add UDP support
This commit is contained in:
parent
799584a210
commit
017c649842
|
@ -107,10 +107,10 @@ void radio_esp8266_setup(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void radio_esp8266_tcp_open(char* host, uint16_t port)
|
void radio_esp8266_open(const char* host, uint16_t port, bool tcp)
|
||||||
{
|
{
|
||||||
char command[256] = {0}; // string to create command
|
char command[256] = {0}; // string to create command
|
||||||
int length = snprintf(command, LENGTH(command), "AT+CIPSTART=\"TCP\",\"%s\",%u\r\n", host, port); // create AT command to establish a TCP connection
|
int length = snprintf(command, LENGTH(command), "AT+CIPSTART=\"%s\",\"%s\",%u\r\n", tcp ? "TCP" : "UDP", host, port); // create AT command to establish a TCP connection
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
radio_esp8266_transmit((uint8_t*)command, length);
|
radio_esp8266_transmit((uint8_t*)command, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,11 @@ extern volatile bool radio_esp8266_success;
|
||||||
void radio_esp8266_setup(void);
|
void radio_esp8266_setup(void);
|
||||||
/** establish TCP connection
|
/** establish TCP connection
|
||||||
* @param[in] host host to connect to
|
* @param[in] host host to connect to
|
||||||
* @param[in] port TCP port to connect to
|
* @param[in] port port number to connect to
|
||||||
|
* @param[in] tcp if connect to a TCP port (else UDP)
|
||||||
* @note wait for activity to get success status
|
* @note wait for activity to get success status
|
||||||
*/
|
*/
|
||||||
void radio_esp8266_tcp_open(char* host, uint16_t port);
|
void radio_esp8266_open(const char* host, uint16_t port, bool tcp);
|
||||||
/** send data (requires established connection)
|
/** send data (requires established connection)
|
||||||
* @param[in] data data to send
|
* @param[in] data data to send
|
||||||
* @param[in] length size of data to send
|
* @param[in] length size of data to send
|
||||||
|
|
Loading…
Reference in New Issue