Shared Wifi resources and Network connection. Complex Question about using Semaphore

allacmc
Posts: 6
Joined: Fri Nov 24, 2023 4:32 pm

Shared Wifi resources and Network connection. Complex Question about using Semaphore

Postby allacmc » Thu Jun 20, 2024 4:02 pm

<r>I would like the following help:<br/>
<br/>
I have a complex hardware that works with ESP32 S3 16MB of Ram and ESP IDF 5<br/>
<br/>
The function of this hardware is to connect to Wifi and ping different IP devices.<br/>
<br/>
This ping command is not done multiple times. I mean that I don’t call the ping function several times. I wait for one ping to finish and start another.<br/>
<br/>
I did it this way, because I understand that it was safer.<br/>
<br/>
However, on this same hardware I have two MQTT connections, one connection sends information every 1 minute and another connection listens to a topic that can receive data every moment.<br/>
<br/>
My question is is this connection to the wifi hardware a system restriction? Do I have to apply a Semaphoro or event group to each thing?<br/>
<br/>
Currently MQTT and Ping run at the same time. But I don’t know if it’s correct.<br/>
<br/>
What do you think ?<br/>
<br/>
I’m going to paste a part of the code here so you can understand a little of the context and also a photo of the product.<br/>

<CODEBOX codebox="c" file="Untitled.c"><s>
  1. </s>void v_Pingador(void *parameters) {<br/>
  2.     while(1){<br/>
  3.         for (int i = 0; i < MAX_IP_COUNT; i++) {<br/>
  4.             if (Device[i].Servico != NULL && strcmp(Device[i].Servico, "ping") == 0) {<br/>
  5.                 if(f_Ipv4Valid(Device[i].ip_addresses)){<br/>
  6.                     xEventGroupWaitBits(xEventGroupWifi, WIFI_BIT_0, pdFALSE, pdFALSE, portMAX_DELAY);<br/>
  7.                     xSemaphoreTake(SemaphorePing, portMAX_DELAY);<br/>
  8.                     f_Ping((void *)&Device[i]);<br/>
  9.                 }<br/>
  10.             }<br/>
  11.         }<br/>
  12.     }<br/>
  13. }<br/>
  14. <br/>
  15. void f_CoreSubscribe(){<br/>
  16.     for (int i = 0; i < MAX_IP_COUNT; i++) {<br/>
  17.         if (Device[i].Servico != NULL && strcmp(Device[i].Servico, "mqtt") == 0) {<br/>
  18.             if(Device[i].topico != NULL){<br/>
  19.                 if(f_ValidaTopico(Device[i].topico)){<br/>
  20.                     f_subscribe(Device[i].topico);<br/>
  21.                 }<br/>
  22.             }<br/>
  23.         }<br/>
  24.     }<br/>
  25. }<br/>
  26. <br/>
  27. void v_Display_0(void *pvParameters) {<br/>
  28.     int8_t Alarme_Device;<br/>
  29.     int32_t TimeOut_Count[MAX_IP_COUNT];<br/>
  30.     unsigned long received_item;<br/>
  31.     char ms_str[22];<br/>
  32.     char ms_str2[26];<br/>
  33.     while(1) {<br/>
  34.         char * receivedMqtt;<br/>
  35.         for (int i=0; i<MAX_IP_COUNT;i++){<br/>
  36.             xEventGroupWaitBits(EventG_Display, BIT_0, pdFALSE, pdFALSE, portMAX_DELAY);<br/>
  37.             if (Device[i].xQueue!=NULL){<br/>
  38.                 if (Device[i].Servico != NULL && strcmp(Device[i].Servico, "ping") == 0){<br/>
  39.                         if (xQueueReceive(Device[i].xQueue, &received_item, 0)) {<br/>
  40.                             if (received_item != UINT32_MAX){<br/>
  41.                                 snprintf(ms_str, sizeof(ms_str), "Tempo - %ldms", received_item);<br/>
  42.                                 f_Mostra(ms_str, Device[i].ip_addresses, Device[i].Device_Name, Clear_OFF, i);<br/>
  43.                                 TimeOut_Count[i] = 0;<br/>
  44.                             }else{<br/>
  45.                                 snprintf(ms_str2, sizeof(ms_str2), "%s - Outs:%lu", Device[i].Device_Name, TimeOut_Count[i]+1);<br/>
  46.                                 f_Mostra("TIME OUT!!", Device[i].ip_addresses, ms_str2, Clear_ON, i);<br/>
  47.                                 TimeOut_Count[i]++;<br/>
  48.                             }<br/>
  49.                             EventBits_t bits = xEventGroupGetBits(EventG_Alarme);<br/>
  50.                             if(TimeOut_Count[i]>Alarme_NumAtivarStatus && !(bits & BIT_0)){<br/>
  51.                                 xEventGroupSetBits(EventG_Alarme, BIT_0);<br/>
  52.                                 f_Led(LED_VERDE, Led_Desliga);<br/>
  53.                                 urlFinal = f_urlFinal(AlarmeWebHookURL_val, AlarmeWebHookText_val, Device[i].Device_Name, Device[i].ip_addresses);<br/>
  54.                                 Alarme_Device = i;<br/>
  55.                                 AlarmeSonoroSuprimir = true;<br/>
  56.                             }else if(i == Alarme_Device && TimeOut_Count[i] == 0 && (bits & BIT_0)){<br/>
  57.                                 xEventGroupClearBits(EventG_Alarme, BIT_0);<br/>
  58.                                 AlarmeSonoroSuprimir = false;<br/>
  59.                                 f_Led(LED_VERDE, Led_Liga);<br/>
  60.                                 ESP_LOGW(TAG, "Led Verde...ligado");<br/>
  61.                             }<br/>
  62.                         }<br/>
  63.                 } else if (Device[i].Servico != NULL && strcmp(Device[i].Servico, "mqtt") == 0){<br/>
  64.                     if (xQueueReceive(Device[i].xQueue, &receivedMqtt, 0)) {<br/>
  65.                         f_Mostra(receivedMqtt, Device[i].topico,Device[i].Device_Name, Clear_OFF, i);<br/>
  66.                     }<br/>
  67.                     <br/>
  68.                 }<br/>
  69.             }<br/>
  70.             else{<br/>
  71.                 if (Texto_Display_Vazio != NULL && (strlen(Texto_Display_Vazio)>3)) {<br/>
  72.                     f_Mostra("", "", Texto_Display_Vazio, Clear_OFF, i);<br/>
  73.                 }<br/>
  74.             }<br/>
  75.             //ESP_LOGW(TAG, "Device[%i]", i);<br/>
  76.         }<br/>
  77.         vPortYield();<br/>
  78.     }<br/>
  79. }<e>
</e></CODEBOX>

<br/>
and<br/>
<br/>
The ping code:<br/>

<CODEBOX codebox="c" file="Untitled.c"><s>
  1. </s>void on_ping_success(esp_ping_handle_t hdl, void *args) {<br/>
  2.         uint32_t elapsed_time_ms;<br/>
  3.         esp_err_t ret;<br/>
  4.         ip_addr_t target_addr;<br/>
  5.         device_t *Device_X = (device_t *)args;<br/>
  6.         ret = esp_ping_get_profile(hdl, ESP_PING_PROF_TIMEGAP, &elapsed_time_ms, sizeof(uint32_t));<br/>
  7.         if (ret != ESP_OK) {ESP_LOGE("TAG", "Erro ao obter o tempo decorrido: %d", ret);return;}<br/>
  8.         ret = esp_ping_get_profile(hdl, ESP_PING_PROF_IPADDR, &target_addr, sizeof(ip_addr_t));<br/>
  9.         if (ret != ESP_OK) {ESP_LOGE("TAG", "Erro ao obter o endereço IP alvo: %d", ret);return;}<br/>
  10.         xQueueSend(Device_X->xQueue, &elapsed_time_ms, 100);<br/>
  11. }<br/>
  12. <br/>
  13. void on_ping_timeout(esp_ping_handle_t hdl, void *args) {<br/>
  14.     esp_err_t ret;<br/>
  15.     ip_addr_t target_addr;<br/>
  16.     device_t *Device_X = (device_t *)args;<br/>
  17.     ret = esp_ping_get_profile(hdl, ESP_PING_PROF_IPADDR, &target_addr, sizeof(ip_addr_t));<br/>
  18.     if (ret != ESP_OK) {ESP_LOGE("TAG", "Erro ao obter o endereço IP alvo: %d", ret);return;}<br/>
  19.     uint32_t Max =  UINT32_MAX;<br/>
  20.     xQueueSend(Device_X->xQueue, &Max, 100);<br/>
  21. }<br/>
  22. <br/>
  23. void on_ping_end(esp_ping_handle_t hdl, void *args) {<br/>
  24.         esp_err_t ret;<br/>
  25.         ret = esp_ping_delete_session(hdl);<br/>
  26.         if (ret != ESP_OK) {printf("Erro ao encerrar a sessão de ping: %d\n", ret);return;}<br/>
  27.         ip_addr_t target_addr;<br/>
  28.         ret = esp_ping_get_profile(hdl, ESP_PING_PROF_IPADDR, &target_addr, sizeof(ip_addr_t));<br/>
  29.         xSemaphoreGive(SemaphorePing);<br/>
  30. }<br/>
  31. <br/>
  32. void f_Ping(void *parameters) {<br/>
  33.         device_t *Device_X = (device_t *)parameters;<br/>
  34.         if (f_PingValida(Device_X)==false) {xSemaphoreGive(SemaphorePing);return;}<br/>
  35.         ip_addr_t ip;<br/>
  36.         ip.u_addr.ip4.addr = esp_ip4addr_aton(Device_X->ip_addresses);<br/>
  37.         ip.type = IPADDR_TYPE_V4;<br/>
  38.         esp_ping_config_t ping_config = {<br/>
  39.             .target_addr = ip, // Endereço IP do host a ser pingado<br/>
  40.             .count = Device_X->count, // Número de pacotes a serem enviados<br/>
  41.             .interval_ms = Device_X->interval_ms, // Intervalo entre os envios de pacotes (em milissegundos)<br/>
  42.             .data_size = Device_X->data_size, // Tamanho dos dados do pacote ICMP<br/>
  43.             .timeout_ms = Device_X->timeout_ms, // Tempo limite para esperar por uma resposta (em milissegundos)<br/>
  44.             .tos = Device_X->tos, // Tipo de Serviço (TOS) para o pacote IP<br/>
  45.             .ttl = Device_X->ttl, // Tempo de Vida (TTL) do pacote IP<br/>
  46.             //.interface = NULL, // Interface de rede a ser usada para o ping (NULL para usar a interface padrão)<br/>
  47.             .task_stack_size = 3000,<br/>
  48.             .task_prio = 5<br/>
  49.         };<br/>
  50.         esp_ping_callbacks_t ping_callbacks = {.on_ping_success = on_ping_success,.on_ping_timeout = on_ping_timeout,.on_ping_end = on_ping_end,.cb_args = (void *)Device_X};<br/>
  51.         esp_ping_handle_t ping_handle;<br/>
  52.         esp_err_t ret = esp_ping_new_session(&ping_config, &ping_callbacks, &ping_handle);<br/>
  53.         if (ret != ESP_OK) {printf("Erro ao criar a sessão de ping: %d\n", ret);ESP_LOGE(TAG, "IP[%s]", Device_X->ip_addresses);xSemaphoreGive(SemaphorePing);return;}<br/>
  54.         ret = esp_ping_start(ping_handle);<br/>
  55.         if (ret != ESP_OK) {printf("Erro ao iniciar o ping: %d\n", ret);ESP_LOGW(TAG, "IP[%s]", Device_X->ip_addresses);xSemaphoreGive(SemaphorePing);return;}<br/>
  56. }<e>
</e></CODEBOX>

The MQTT Code:<br/>

<CODEBOX codebox="c" file="Untitled.c"><s>
  1. </s>
  2. //-----------------------------------------------------------------------------------------------------------------------<br/>
  3. //---MQTT 1--------------------------------------------------------------------------------------------------------------<br/>
  4. //-----------------------------------------------------------------------------------------------------------------------<br/>
  5.         static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data){<br/>
  6.             ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id);<br/>
  7.             esp_mqtt_event_handle_t event = event_data;<br/>
  8.             esp_mqtt_client_handle_t client = event->client;<br/>
  9.             switch ((esp_mqtt_event_id_t)event_id) {<br/>
  10.             case MQTT_EVENT_CONNECTED:<br/>
  11.                 ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");<br/>
  12.                 f_CoreSubscribe();<br/>
  13.                 break;<br/>
  14.             case MQTT_EVENT_DISCONNECTED:<br/>
  15.                 ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");<br/>
  16.                 break;<br/>
  17.             case MQTT_EVENT_DATA:<br/>
  18.                 char *topic = strndup(event->topic, event->topic_len);<br/>
  19.                 char *data = strndup(event->data, event->data_len);<br/>
  20.                 if (topic && data) {f_SendDataMqtt(topic, data);} else {ESP_LOGE(TAG, "Falha ao alocar memória para tópico ou payload");}<br/>
  21.                 free(topic);free(data);<br/>
  22.                 break;<br/>
  23.             case MQTT_EVENT_ERROR:<br/>
  24.                 ESP_LOGI(TAG, "MQTT_EVENT_ERROR");<br/>
  25.                 if (event->error_handle->error_type == MQTT_ERROR_TYPE_TCP_TRANSPORT) {<br/>
  26.                     log_error_if_nonzero("reported from esp-tls", event->error_handle->esp_tls_last_esp_err);<br/>
  27.                     log_error_if_nonzero("reported from tls stack", event->error_handle->esp_tls_stack_err);<br/>
  28.                     log_error_if_nonzero("captured as transport's socket errno",  event->error_handle->esp_transport_sock_errno);<br/>
  29.                     ESP_LOGI(TAG, "Last errno string (%s)", strerror(event->error_handle->esp_transport_sock_errno));<br/>
  30.                 }<br/>
  31.                 break;<br/>
  32.             default:<br/>
  33.                 ESP_LOGI(TAG, "Other event id:%d", event->event_id);<br/>
  34.                 break;<br/>
  35.             }<br/>
  36.         }<br/>
  37. //-----------------------------------------------------------------------------------------------------------------------<br/>
  38. //---MQTT 2--------------------------------------------------------------------------------------------------------------<br/>
  39. //-----------------------------------------------------------------------------------------------------------------------<br/>
  40.         static void mqtt_event_handler_out(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data){<br/>
  41.             ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id);<br/>
  42.             esp_mqtt_event_handle_t event = event_data;<br/>
  43.             esp_mqtt_client_handle_t client = event->client;<br/>
  44.             switch ((esp_mqtt_event_id_t)event_id) {<br/>
  45.             case MQTT_EVENT_CONNECTED:<br/>
  46.                 ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");<br/>
  47.                 esp_mqtt_client_subscribe(client, TOPICO_OTA, 0);<br/>
  48.                 esp_mqtt_client_subscribe(client, TOPICO_URL, 0);<br/>
  49.                 esp_mqtt_client_subscribe(client, f_topico(TOPICO_LICENCA), 0);<br/>
  50.                 f_mqttPublica(f_topico(zMQTT_sufixo), f_prepJsonConfig(mqtt_ON), cMqttOut);<br/>
  51.                 f_mqttPublica(f_topico(zMQTT_sufixo_Config), f_prepJsonConfig(mqtt_Config), cMqttOut);<br/>
  52.                 break;<br/>
  53.             case MQTT_EVENT_DISCONNECTED:<br/>
  54.                 ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");<br/>
  55.                 break;<br/>
  56.             case MQTT_EVENT_DATA:<br/>
  57.                 ESP_LOGI(TAG, "MQTT_EVENT_DATA");<br/>
  58.                 printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);<br/>
  59.                 printf("DATA=%.*s\r\n", event->data_len, event->data);<br/>
  60.                 //Testa qual tópico foi recebido e começa a fazer as coisas conforme o tópico<br/>
  61.                 if (strncmp(event->topic, TOPICO_OTA, event->topic_len) == 0) {<br/>
  62.                     f_otaMQTT(event->topic, event->topic_len, event->data, event->data_len);<br/>
  63.                 }<br/>
  64.                 if (strncmp(event->topic, TOPICO_URL, event->topic_len) == 0) {<br/>
  65.                     ESP_LOGW(TAG, "TOPICO URL");//Desenvolver ainda...<br/>
  66.                 }<br/>
  67.                 if (strncmp(event->topic, f_topico(TOPICO_LICENCA), event->topic_len) == 0) {<br/>
  68.                     cJSON *token = cJSON_GetObjectItem(cJSON_Parse((char *)event->data), "token");<br/>
  69.                     if (!cJSON_IsString(token)){ESP_LOGE(TAG, "Erro na leitura do json");}<br/>
  70.                     f_nvsSet(zTokenTemp, token->valuestring, false);<br/>
  71.                     xTaskCreatePinnedToCore(v_InsertLicenca, "v_InsertLicenca", 8000, NULL, tskIDLE_PRIORITY, NULL, tskNO_AFFINITY);<br/>
  72.                 }<br/>
  73.                 break;<br/>
  74.             case MQTT_EVENT_ERROR:<br/>
  75.                 ESP_LOGI(TAG, "MQTT_EVENT_ERROR");<br/>
  76.                 if (event->error_handle->error_type == MQTT_ERROR_TYPE_TCP_TRANSPORT) {<br/>
  77.                     log_error_if_nonzero("reported from esp-tls", event->error_handle->esp_tls_last_esp_err);<br/>
  78.                     log_error_if_nonzero("reported from tls stack", event->error_handle->esp_tls_stack_err);<br/>
  79.                     log_error_if_nonzero("captured as transport's socket errno",  event->error_handle->esp_transport_sock_errno);<br/>
  80.                     ESP_LOGI(TAG, "Last errno string (%s)", strerror(event->error_handle->esp_transport_sock_errno));<br/>
  81.                 }<br/>
  82.                 break;<br/>
  83.             default:<br/>
  84.                 ESP_LOGI(TAG, "Other event id:%d", event->event_id);<br/>
  85.                 break;<br/>
  86.             }<br/>
  87.         }<br/>
  88. <br/>
  89. <br/>
  90. void f_mqttPublica(const char * topico, const char * payload, esp_mqtt_client_handle_t handle){<br/>
  91.      EventBits_t bits = xEventGroupWaitBits(xEventGroupWifi, WIFI_BIT_0, pdFALSE, pdFALSE, 200);<br/>
  92.      if((bits & WIFI_BIT_0)){<br/>
  93.           int len = strlen(payload);<br/>
  94.           //xSemaphoreTake(SemaphorePing, portMAX_DELAY);<br/>
  95.           int resp = esp_mqtt_client_publish(handle, topico,payload,len,0,0);<br/>
  96.           if (resp==0){<br/>
  97.              ESP_LOGI(TAG, "JSON publicado via MQTT. Com sucesso");<br/>
  98.           }else if(resp<0){<br/>
  99.              ESP_LOGE(TAG, "JSON publicado via MQTT. Erro na publicação");<br/>
  100.           }<br/>
  101.           //xSemaphoreGive(SemaphorePing);<br/>
  102.      }<br/>
  103. }<br/>
  104. <br/>
  105. extern const uint8_t ca_cert_pem_start[] asm("_binary_ca_cert_pem_start");<br/>
  106. extern const uint8_t ca_cert_pem_end[] asm("_binary_ca_cert_pem_end");<br/>
  107. <br/>
  108. void f_setupMQTT(void){<br/>
  109.     Dados_Mqtt_t DadosMqtt, DadosMqttout;<br/>
  110.     if(f_DadosMqtt(&DadosMqtt) == ESP_OK){<br/>
  111.                 ESP_LOGW(TAG, "MQTT");<br/>
  112.                 //ESP_LOGW(TAG, "cert:%s", DadosMqtt.mqtt_cert);<br/>
  113.                 //ESP_LOGW(TAG, "cert:%i", DadosMqtt.mqtt_cert_len);<br/>
  114.                 esp_mqtt_client_config_t mqtt_cfg = {<br/>
  115.                 .broker.address.uri = DadosMqtt.mqtt_server,<br/>
  116.                 .broker.address.port = DadosMqtt.mqtt_port,<br/>
  117.                 .broker.verification.certificate = (const char *)ca_cert_pem_start,<br/>
  118.                 .broker.verification.certificate_len = (ca_cert_pem_end - ca_cert_pem_start),<br/>
  119.                 //.broker.verification.certificate = DadosMqtt.mqtt_cert,<br/>
  120.                 //.broker.verification.certificate_len = DadosMqtt.mqtt_cert_len,<br/>
  121.                 .credentials.username = DadosMqtt.mqtt_user,<br/>
  122.                 .credentials.authentication.password = DadosMqtt.mqtt_pass,<br/>
  123.                 .credentials.client_id = "enervision",<br/>
  124.                 .session.last_will.msg = f_prepJsonConfig(mqtt_OFF),<br/>
  125.                 .session.last_will.msg_len = strlen(f_prepJsonConfig(mqtt_OFF)),<br/>
  126.                 .session.last_will.topic = f_topico(zMQTT_sufixo),<br/>
  127.                 .session.last_will.retain = true,<br/>
  128.                 .session.last_will.qos = 1,<br/>
  129.                 .session.keepalive = 2        <br/>
  130.             };<br/>
  131. <br/>
  132.                 //Fazer isso no futuro - v.2.0  //Não conectou ... Busca o backup por OTA ?<br/>
  133.                 //Antes de buscar a conexão via backup, conferir conexões, ping, verificar se o dns <br/>
  134.             EventBits_t bits = xEventGroupWaitBits(xEventGroupWifi, WIFI_BIT_0, pdFALSE, pdFALSE, pdMS_TO_TICKS(40000));<br/>
  135.             if((bits & WIFI_BIT_0)){<br/>
  136.                 client = esp_mqtt_client_init(&mqtt_cfg);<br/>
  137.                 esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL);<br/>
  138.                 esp_mqtt_client_start(client);<br/>
  139.             }<br/>
  140.     }<br/>
  141.     <br/>
  142.     if(f_DadosMqttout(&DadosMqttout) == ESP_OK){<br/>
  143.             ESP_LOGW(TAG, "MQTT OUT");<br/>
  144.             esp_mqtt_client_config_t mqtt_cfg_out = {<br/>
  145.                 .broker.address.uri = DadosMqttout.mqtt_server,<br/>
  146.                 .broker.address.port = DadosMqttout.mqtt_port,<br/>
  147.                 .broker.verification.certificate = (const char *)ca_cert_pem_start,<br/>
  148.                 .broker.verification.certificate_len = (ca_cert_pem_end - ca_cert_pem_start),<br/>
  149.                 .credentials.username = DadosMqttout.mqtt_user,<br/>
  150.                 .credentials.authentication.password = DadosMqttout.mqtt_pass,<br/>
  151.                 .credentials.client_id = f_serialNumber(),<br/>
  152.                 .session.last_will.msg = f_prepJsonConfig(mqtt_OFF),<br/>
  153.                 .session.last_will.msg_len = strlen(f_prepJsonConfig(mqtt_OFF)),<br/>
  154.                 .session.last_will.topic = f_topico(zMQTT_sufixo),<br/>
  155.                 .session.last_will.retain = true,<br/>
  156.                 .session.last_will.qos = 1,<br/>
  157.                 .session.keepalive = 2        <br/>
  158.             };<br/>
  159.             EventBits_t bits = xEventGroupWaitBits(xEventGroupWifi, WIFI_BIT_0, pdFALSE, pdFALSE, pdMS_TO_TICKS(40000));<br/>
  160.             if((bits & WIFI_BIT_0)){<br/>
  161.                 cMqttOut = esp_mqtt_client_init(&mqtt_cfg_out);<br/>
  162.                 esp_mqtt_client_register_event(cMqttOut, ESP_EVENT_ANY_ID, mqtt_event_handler_out, NULL);<br/>
  163.                 esp_mqtt_client_start(cMqttOut);<br/>
  164.             }<br/>
  165.     }<br/>
  166. }
  167. <e>
</e></CODEBOX>

My Setup Screen:</r>
Attachments
Captura de tela 2024-06-20 125553.png
Captura de tela 2024-06-20 125553.png (927.83 KiB) Viewed 1502 times
Captura de tela 2024-06-20 125531.png
Captura de tela 2024-06-20 125531.png (1020.9 KiB) Viewed 1502 times
Captura de tela 2024-06-20 125512.png
Captura de tela 2024-06-20 125512.png (73.35 KiB) Viewed 1502 times
Allan Caldas - Enervision Telemetria

MicroController
Posts: 1707
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Shared Wifi resources and Network connection. Complex Question about using Semaphore

Postby MicroController » Fri Jun 21, 2024 8:32 pm

My question is is this connection to the wifi hardware a system restriction? Do I have to apply a Semaphoro or event group to each thing?
You can concurrently use as many connections (sockets) as you want (limited by available RAM); the network stack gets the hardware/WiFi access sorted out for you, no need for 'manual' synchronization.

I'm not sure about concurrent accesses on a single connection/socket, but that doesn't seem to be an issue for you.

allacmc
Posts: 6
Joined: Fri Nov 24, 2023 4:32 pm

Re: Shared Wifi resources and Network connection. Complex Question about using Semaphore

Postby allacmc » Wed Jul 03, 2024 2:47 am

So the expressif libraries already know how to deal with concurrent connections automatically?

I don't need to manually worry about this?
Allan Caldas - Enervision Telemetria

Who is online

Users browsing this forum: Majestic-12 [Bot] and 100 guests