@@ -21,14 +21,14 @@ command_result net_open(CommandableIf *t)
21
21
ESP_LOGV (TAG, " %s" , __func__);
22
22
23
23
// Set WiFi mode to station
24
- auto ret = dce_commands::generic_command (t, " AT+CWMODE=1\r " , " OK" , " ERROR" , 5000 );
24
+ auto ret = dce_commands::generic_command (t, " AT+CWMODE=1\r\n " , " OK" , " ERROR" , 5000 );
25
25
if (ret != command_result::OK) {
26
26
ESP_LOGE (TAG, " Failed to set WiFi mode" );
27
27
return ret;
28
28
}
29
29
30
30
// Connect to WiFi network
31
- std::string wifi_cmd = " AT+CWJAP=\" " CONFIG_EXAMPLE_WIFI_SSID " \" ,\" " CONFIG_EXAMPLE_WIFI_PASSWORD " \"\r " ;
31
+ std::string wifi_cmd = " AT+CWJAP=\" " CONFIG_EXAMPLE_WIFI_SSID " \" ,\" " CONFIG_EXAMPLE_WIFI_PASSWORD " \"\r\n " ;
32
32
ret = dce_commands::generic_command (t, wifi_cmd, " OK" , " ERROR" , 15000 );
33
33
if (ret != command_result::OK) {
34
34
ESP_LOGE (TAG, " Failed to connect to WiFi" );
@@ -43,7 +43,7 @@ command_result net_close(CommandableIf *t)
43
43
{
44
44
ESP_LOGV (TAG, " %s" , __func__);
45
45
// Disconnect from WiFi
46
- auto ret = dce_commands::generic_command (t, " AT+CWQAP\r " , " OK" , " ERROR" , 5000 );
46
+ auto ret = dce_commands::generic_command (t, " AT+CWQAP\r\n " , " OK" , " ERROR" , 5000 );
47
47
if (ret != command_result::OK) {
48
48
ESP_LOGW (TAG, " Failed to disconnect WiFi (may already be disconnected)" );
49
49
}
@@ -55,13 +55,13 @@ command_result tcp_open(CommandableIf *t, const std::string &host, int port, int
55
55
ESP_LOGV (TAG, " %s" , __func__);
56
56
57
57
// Set single connection mode (just in case)
58
- auto ret = dce_commands::generic_command (t, " AT+CIPMUX=0\r " , " OK" , " ERROR" , 1000 );
58
+ auto ret = dce_commands::generic_command (t, " AT+CIPMUX=0\r\n " , " OK" , " ERROR" , 1000 );
59
59
if (ret != command_result::OK) {
60
60
ESP_LOGW (TAG, " Failed to set single connection mode" );
61
61
}
62
62
63
63
// Establish TCP connection
64
- std::string tcp_cmd = " AT+CIPSTART=\" TCP\" ,\" " + host + " \" ," + std::to_string (port) + " \r " ;
64
+ std::string tcp_cmd = " AT+CIPSTART=\" TCP\" ,\" " + host + " \" ," + std::to_string (port) + " \r\n " ;
65
65
ret = dce_commands::generic_command (t, tcp_cmd, " CONNECT" , " ERROR" , timeout);
66
66
if (ret != command_result::OK) {
67
67
ESP_LOGE (TAG, " Failed to establish TCP connection to %s:%d" , host.c_str (), port);
@@ -75,7 +75,7 @@ command_result tcp_open(CommandableIf *t, const std::string &host, int port, int
75
75
command_result tcp_close (CommandableIf *t)
76
76
{
77
77
ESP_LOGV (TAG, " %s" , __func__);
78
- return dce_commands::generic_command (t, " AT+CIPCLOSE\r " , " CLOSED" , " ERROR" , 5000 );
78
+ return dce_commands::generic_command (t, " AT+CIPCLOSE\r\n " , " CLOSED" , " ERROR" , 5000 );
79
79
}
80
80
81
81
command_result tcp_send (CommandableIf *t, uint8_t *data, size_t len)
@@ -98,7 +98,7 @@ command_result get_ip(CommandableIf *t, std::string &ip)
98
98
{
99
99
ESP_LOGV (TAG, " %s" , __func__);
100
100
std::string out;
101
- auto ret = dce_commands::generic_get_string (t, " AT+CIFSR\r " , out, 5000 );
101
+ auto ret = dce_commands::at_raw (t, " AT+CIFSR\r\n " , out, " OK " , " ERROR " , 5000 );
102
102
if (ret != command_result::OK) {
103
103
return ret;
104
104
}
@@ -122,10 +122,10 @@ command_result get_ip(CommandableIf *t, std::string &ip)
122
122
123
123
command_result set_rx_mode (CommandableIf *t, int mode)
124
124
{
125
- ESP_LOGV (TAG, " %s" , __func__);
125
+ ESP_LOGE (TAG, " %s" , __func__);
126
126
// Set passive receive mode (1) for better control
127
127
// Active mode (0) would send +IPD automatically
128
- std::string cmd = " AT+CIPRECVTYPE=" + std::to_string (mode) + " \r " ;
128
+ std::string cmd = " AT+CIPRECVTYPE=" + std::to_string (mode) + " \r\n " ;
129
129
return dce_commands::generic_command (t, cmd, " OK" , " ERROR" , 1000 );
130
130
}
131
131
@@ -137,17 +137,17 @@ void Responder::start_sending(size_t len)
137
137
{
138
138
data_to_send = len;
139
139
send_stat = 0 ;
140
- send_cmd (" AT+CIPSEND=" + std::to_string (len) + " \r " );
140
+ send_cmd (" AT+CIPSEND=" + std::to_string (len) + " \r\n " );
141
141
}
142
142
143
143
void Responder::start_receiving (size_t len)
144
144
{
145
- send_cmd (" AT+CIPRECVDATA=" + std::to_string (len) + " \r " );
145
+ send_cmd (" AT+CIPRECVDATA=" + std::to_string (len) + " \r\n " );
146
146
}
147
147
148
148
bool Responder::start_connecting (std::string host, int port)
149
149
{
150
- std::string cmd = " AT+CIPSTART=\" TCP\" ,\" " + host + " \" ," + std::to_string (port) + " \r " ;
150
+ std::string cmd = " AT+CIPSTART=\" TCP\" ,\" " + host + " \" ," + std::to_string (port) + " \r\n " ;
151
151
send_cmd (cmd);
152
152
return true ;
153
153
}
0 commit comments