Access Point and Server
Posted: Wed Dec 07, 2016 10:01 pm
I am looking for code to create REST server in AP mode. What I have.
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) );
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &wifi_config) );
struct sockaddr_in socketAddress;
memset(&socketAddress, 0, sizeof(socketAddress));
socketAddress.sin_family = AF_INET;
socketAddress.sin_addr.s_addr = htonl(INADDR_ANY);
socketAddress.sin_port = htons(80);
int ret = bind(socket, (struct sockaddr *)&socketAddress, sizeof(socketAddress));
if (ret) {ESP_LOGI(TAG, "failed 1!"); goto network_task_finish;}
ret = listen(socket, 32);
if (ret) {ESP_LOGI(TAG, "failed 2!"); goto network_task_finish;}
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) );
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &wifi_config) );
struct sockaddr_in socketAddress;
memset(&socketAddress, 0, sizeof(socketAddress));
socketAddress.sin_family = AF_INET;
socketAddress.sin_addr.s_addr = htonl(INADDR_ANY);
socketAddress.sin_port = htons(80);
int ret = bind(socket, (struct sockaddr *)&socketAddress, sizeof(socketAddress));
if (ret) {ESP_LOGI(TAG, "failed 1!"); goto network_task_finish;}
ret = listen(socket, 32);
if (ret) {ESP_LOGI(TAG, "failed 2!"); goto network_task_finish;}