550 static void task_HTTPserver(void* pvParameters) |
550 static void task_HTTPserver(void* pvParameters) |
551 { |
551 { |
552 struct netconn *conn, *newconn; |
552 struct netconn *conn, *newconn; |
553 static err_t err; |
553 static err_t err; |
554 |
554 |
555 ESP_LOGI(TAG, "Start http server_task"); |
555 ESP_LOGI(TAG, "Start HTTP/web server"); |
556 client_queue = xQueueCreate(client_queue_size,sizeof(struct netconn*)); |
|
557 |
556 |
558 conn = netconn_new(NETCONN_TCP); |
557 conn = netconn_new(NETCONN_TCP); |
559 netconn_bind(conn,NULL,80); |
558 netconn_bind(conn,NULL,80); |
560 netconn_listen(conn); |
559 netconn_listen(conn); |
561 |
560 |
584 { |
583 { |
585 struct netconn* conn; |
584 struct netconn* conn; |
586 |
585 |
587 ESP_LOGI(TAG, "Start Queue task"); |
586 ESP_LOGI(TAG, "Start Queue task"); |
588 for(;;) { |
587 for(;;) { |
589 xQueueReceive(client_queue, &conn, portMAX_DELAY); |
588 xQueueReceive(client_queue, &(conn), portMAX_DELAY); |
590 if (!conn) |
589 if (!conn) |
591 continue; |
590 continue; |
592 http_serve(conn); |
591 http_serve(conn); |
593 vTaskDelay(2 / portTICK_PERIOD_MS); |
592 vTaskDelay(2 / portTICK_PERIOD_MS); |
594 } |
593 } |
600 |
599 |
601 void start_http_websocket(void) |
600 void start_http_websocket(void) |
602 { |
601 { |
603 ESP_LOGI(TAG, "Start HTTP/Websocket server"); |
602 ESP_LOGI(TAG, "Start HTTP/Websocket server"); |
604 |
603 |
|
604 client_queue = xQueueCreate(client_queue_size,sizeof(struct netconn*)); |
|
605 if (client_queue == 0) { |
|
606 ESP_LOGE(TAG, "Failed to create client_queue"); |
|
607 return; |
|
608 } |
|
609 |
605 ws_server_start(); |
610 ws_server_start(); |
606 xTaskCreate(&task_HTTPserver, "HTTPserver", 4000, NULL, 9, &xTaskHTTP); |
611 xTaskCreate(&task_HTTPserver, "HTTPserver", 5000, NULL, 9, &xTaskHTTP); |
607 xTaskCreate(&task_Queue, "Queue", 5000, NULL, 6, &xTaskQueue); |
612 xTaskCreate(&task_Queue, "Queue", 6000, NULL, 6, &xTaskQueue); |
608 } |
613 } |
609 |
614 |