@@ -137,7 +137,7 @@ static eppp_channel_fn_t s_tx;
137
137
static esp_err_t remote_wifi_receive (void * h , void * buffer , size_t len )
138
138
{
139
139
if (s_wifi_netif ) {
140
- printf ("recv %d\n" , len );
140
+ // printf("recv %d\n", len);
141
141
return esp_netif_receive (s_wifi_netif , buffer , len , NULL );
142
142
}
143
143
return ESP_OK ;
@@ -146,7 +146,7 @@ static esp_err_t remote_wifi_receive(void *h, void *buffer, size_t len)
146
146
esp_err_t remote_wifi_transmit_wrap (void * h , void * buffer , size_t len , void * netstack_buffer )
147
147
{
148
148
if (s_tx ) {
149
- printf ("send %d\n" , len );
149
+ // printf("send %d\n", len);
150
150
return s_tx (s_ppp_netif , buffer , len );
151
151
}
152
152
return ESP_OK ;
@@ -162,7 +162,7 @@ static esp_err_t remote_wifi_transmit(void *h, void *buffer, size_t len)
162
162
163
163
static void wifi_free (void * h , void * buffer )
164
164
{
165
- printf ("wifi_free %p\n" , buffer );
165
+ // printf("wifi_free %p\n", buffer);
166
166
}
167
167
168
168
static void remote_wifi_netif (void )
@@ -183,6 +183,38 @@ static void remote_wifi_netif(void)
183
183
s_wifi_netif = esp_netif_new (& netif_config );
184
184
}
185
185
186
+ static void wifi_init (void * ctx )
187
+ {
188
+ client_init ();
189
+
190
+ wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
191
+ ESP_ERROR_CHECK (esp_wifi_remote_init (& cfg ));
192
+
193
+ wifi_config_t wifi_config = {
194
+ .sta = {
195
+ .ssid = CONFIG_ESP_WIFI_SSID ,
196
+ .password = CONFIG_ESP_WIFI_PASSWORD ,
197
+ },
198
+ };
199
+
200
+ esp_err_t err = esp_wifi_remote_set_mode (WIFI_MODE_STA );
201
+ ESP_LOGI (TAG , "esp_wifi_remote_set_mode() returned = %x" , err );
202
+ ESP_ERROR_CHECK (esp_wifi_remote_set_config (WIFI_IF_STA , & wifi_config ) );
203
+ ESP_ERROR_CHECK (esp_wifi_remote_start () );
204
+ vTaskDelay (pdMS_TO_TICKS (1000 ));
205
+ uint8_t mac [6 ];
206
+ ESP_ERROR_CHECK (esp_wifi_remote_get_mac (WIFI_IF_STA , mac ) );
207
+
208
+ esp_netif_set_mac (s_wifi_netif , mac );
209
+ vTaskDelay (pdMS_TO_TICKS (1000 ));
210
+
211
+ esp_netif_action_start (s_wifi_netif , 0 , 0 , 0 );
212
+ ESP_ERROR_CHECK (esp_wifi_remote_connect () );
213
+
214
+ esp_netif_action_connected (s_wifi_netif , 0 , 0 , 0 );
215
+ vTaskDelete (NULL );
216
+ }
217
+
186
218
void app_main (void )
187
219
{
188
220
ESP_LOGI (TAG , "[APP] Startup.." );
@@ -198,7 +230,8 @@ void app_main(void)
198
230
eppp_config_t config = EPPP_DEFAULT_CLIENT_CONFIG ();
199
231
#if CONFIG_EPPP_LINK_DEVICE_SPI
200
232
config .transport = EPPP_TRANSPORT_SPI ;
201
- config .task .priority = 5 ;
233
+ config .task .priority = 14 ;
234
+ config .spi .freq = 28000000 ;
202
235
#else
203
236
config .transport = EPPP_TRANSPORT_UART ;
204
237
config .uart .tx_io = 10 ;
@@ -217,35 +250,8 @@ void app_main(void)
217
250
return ;
218
251
}
219
252
220
- client_init ();
221
-
222
-
223
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
224
- ESP_LOG_BUFFER_HEXDUMP ("cfg" , & cfg , sizeof (cfg ), ESP_LOG_WARN );
225
- ESP_ERROR_CHECK (esp_wifi_remote_init (& cfg ));
226
-
227
- wifi_config_t wifi_config = {
228
- .sta = {
229
- .ssid = CONFIG_ESP_WIFI_SSID ,
230
- .password = CONFIG_ESP_WIFI_PASSWORD ,
231
- },
232
- };
233
-
234
- esp_err_t err = esp_wifi_remote_set_mode (WIFI_MODE_STA );
235
- ESP_LOGI (TAG , "esp_wifi_remote_set_mode() returned = %x" , err );
236
- ESP_ERROR_CHECK (esp_wifi_remote_set_config (WIFI_IF_STA , & wifi_config ) );
237
- ESP_ERROR_CHECK (esp_wifi_remote_start () );
238
- vTaskDelay (pdMS_TO_TICKS (1000 ));
239
- uint8_t mac [6 ];
240
- ESP_ERROR_CHECK (esp_wifi_remote_get_mac (WIFI_IF_STA , mac ) );
241
253
242
- esp_netif_set_mac (s_wifi_netif , mac );
243
- vTaskDelay (pdMS_TO_TICKS (1000 ));
244
-
245
- esp_netif_action_start (s_wifi_netif , 0 , 0 , 0 );
246
- ESP_ERROR_CHECK (esp_wifi_remote_connect () );
247
-
248
- esp_netif_action_connected (s_wifi_netif , 0 , 0 , 0 );
254
+ xTaskCreate (& wifi_init , "initwifi" , 8192 , NULL , 18 , NULL );
249
255
// // Setup global DNS
250
256
// esp_netif_dns_info_t dns;
251
257
// dns.ip.u_addr.ip4.addr = esp_netif_htonl(CONFIG_EXAMPLE_GLOBAL_DNS);
0 commit comments