Oh oops, I totally forget to do that. I’ve put it in my while(1) loop with a small delay before and it’s working now.
I read the commentary about what it does and realize my mistake.
However, no, with MX_LWIP_Process() running at each loop, I wonder how I can open a tcp socket and send data ? Can I integrate part of the tcp socket creation inside MX_LWIP_Process() function ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
while (1) { /* USER CODE END WHILE */ Delay(2000000); MX_LWIP_Process(); pcb = tcp_new(); ret_val = tcp_connect(pcb, &dest, 1883, callback_Connected); if (ret_val != ERR_OK) printf("\tcp_connect(): Errors on return value, returned value is %d\n", ret_val); /* USER CODE BEGIN 3 */ } err_t callback_Connected(void *arg, struct tcp_pcb *pcb, err_t err) { err = tcp_write(pcb,buf,len,1); tcp_output(pcb); //to make it send the data immediately tcp_close(pcb); return err; } |
thank you for you (fast) help.