Skip to content

Commit b461d81

Browse files
committed
Merge branch 'feature/add_udp_sync_proc_triggle_v3.0' into 'release/v3.0'
Add UDP sync process trigger See merge request sdk/ESP8266_RTOS_SDK!445
2 parents 38b7f83 + 266545e commit b461d81

File tree

5 files changed

+48
-9
lines changed

5 files changed

+48
-9
lines changed

components/lwip/port/esp8266/freertos/sys_arch.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct timeoutlist {
5959
//static u16_t nextthread = 0;
6060
int intlevel = 0;
6161

62+
static xTaskHandle s_tcpip_task_handle;
63+
6264
/*-----------------------------------------------------------------------------------*/
6365
// Initialize sys arch
6466
void
@@ -365,18 +367,27 @@ sys_now(void)
365367
sys_thread_t
366368
sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
367369
{
368-
xTaskHandle CreatedTask;
369370
portBASE_TYPE result;
370371

371-
result = xTaskCreate(thread, (const char *)name, stacksize, arg, prio, &CreatedTask);
372+
result = xTaskCreate(thread, (const char *)name, stacksize, arg, prio, &s_tcpip_task_handle);
372373

373374
if (result == pdPASS) {
374-
return CreatedTask;
375+
return s_tcpip_task_handle;
375376
} else {
376377
return NULL;
377378
}
378379
}
379380

381+
int sys_current_task_is_tcpip(void)
382+
{
383+
return xTaskGetCurrentTaskHandle() == s_tcpip_task_handle ? 1 : 0;
384+
}
385+
386+
char *sys_current_task_name(void)
387+
{
388+
return pcTaskGetTaskName(xTaskGetCurrentTaskHandle());
389+
}
390+
380391
/*
381392
This optional function does a "fast" critical region protection and returns
382393
the previous protection level. This function is only called during very short

components/lwip/port/esp8266/freertos/udp_sync.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ void udp_sync_ack(void *in_msg)
127127
void udp_sync_set_ret(void *netif, int ret)
128128
{
129129
/* Only poll and regitser can set current message */
130-
if (!s_cur_msg) {
130+
if (!s_cur_msg || !sys_current_task_is_tcpip()) {
131131
/* You may use it to debug */
132-
//ESP_LOGE(TAG, "UDP sync ack error, current message is NULL");
132+
//ESP_LOGE(TAG, "UDP sync ack error, current message is %p, task name is %s", s_cur_msg, sys_current_task_name());
133133
return ;
134134
}
135135

@@ -173,12 +173,29 @@ void udp_sync_proc(void)
173173
continue;
174174

175175
udp_sync_send(s_udp_sync[i].msg);
176-
#if 0
177-
//Todo: Add this later
178-
if (s_udp_sync[i].ret != ERR_OK)
176+
177+
if (s_udp_sync[i].ret == ERR_MEM)
179178
break;
180-
#endif
181179
}
182180
}
183181

182+
/*
183+
* @brief NULL function and just as sync message
184+
*/
185+
static void udp_sync_trigger_null(void *p)
186+
{
187+
188+
}
189+
190+
/*
191+
* @brief trigger a UDP sync process
192+
*/
193+
void udp_sync_trigger(void)
194+
{
195+
if (!s_udp_sync_num)
196+
return ;
197+
198+
tcpip_callback_with_block((tcpip_callback_fn)udp_sync_trigger_null, NULL, 0);
199+
}
200+
184201
#endif /* ESP_UDP */

components/lwip/port/esp8266/include/arch/sys_arch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ void sys_thread_sem_deinit(void);
5757
sys_sem_t* sys_thread_sem_get(void);
5858
err_t sys_mutex_trylock(sys_mutex_t *pxMutex);
5959

60+
int sys_current_task_is_tcpip(void);
61+
62+
char *sys_current_task_name(void);
63+
6064
#define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_thread_sem_init()
6165
#define LWIP_NETCONN_THREAD_SEM_FREE() sys_thread_sem_deinit()
6266
#define LWIP_NETCONN_THREAD_SEM_GET() sys_thread_sem_get()

components/lwip/port/esp8266/include/udp_sync.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ void udp_sync_set_ret(void *netif, int ret);
5252
*/
5353
void udp_sync_proc(void);
5454

55+
/*
56+
* @brief trigger a UDP sync process
57+
*/
58+
void udp_sync_trigger(void);
59+
5560
#ifdef __cplusplus
5661
}
5762
#endif

components/lwip/port/esp8266/netif/ethernetif.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ static int low_level_send_cb(esp_aio_t *aio)
208208

209209
pbuf_free(pbuf);
210210

211+
udp_sync_trigger();
212+
211213
return 0;
212214
}
213215

0 commit comments

Comments
 (0)