Reception of POST communication in HTTP AP mode

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KEKA_4568351
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Is it possible to receive HTTP / POST communication in AP mode as in the sample program below?

please tell me.

◆example

static wiced_result_t WiFi_ap_http_receive_callback ( wiced_http_response_stream_t* stream, uint8_t** data, uint16_t* data_length )

{

    ・・・

}

void test()

{

    wiced_result = wiced_network_up(WICED_AP_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER, &s_ap_ip_settings);

    if (WICED_SUCCESS != wiced_result) {

        ・・・

    }

    wiced_result = wiced_http_server_start(&s_ap_http_server, 80, max_sockets, ap_web_pages, WICED_AP_INTERFACE, DEFAULT_URL_PROCESSOR_STACK_SIZE);

    if (WICED_SUCCESS != wiced_result) {

        ・・・

    }

    wiced_result = wiced_http_server_register_callbacks(&s_ap_http_server, WiFi_ap_http_receive_callback, NULL);

    if(WICED_SUCCESS != wiced_result) {

        ・・・

    }

    ・・・

}

<Japanese>

HTTP APモードにおける、POST通信の受信について

以下のサンプルプログラムのように、APモードで、HTTP・POST通信の受信は可能でしょうか。

教えてください。

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Usually, POST method is used to send data to the server. HTTP server for AP mode is not that difficult. Attached is a modified version of  snip.http_server_sent_events but the example does not have POST method because it's usually the other way around.

View solution in original post

0 Likes
9 Replies
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

I have not tested this. But if the http client is connected to the same AP, I don't see the reason you won't receive the http events.

Maybe you can refer to CypressAcademy_WW101_Files/05_httpbin_post.c at master · cypresssemiconductorco/CypressAcademy_WW101... (a STA implementation) and http_server_snip_events inside snip folder to create your own application in AP mode. I am assuming all these are in the context of a local network.

It looks like the sample POST communication of HTTP client.

Thank you for the information, though it is not a sample HTTP server for AP mode.

POST communication of HTTP server in AP mode seems difficult.

<Japanese>

HTTP クライアントのPOST通信サンプルのようです。

APモードにHTTPサーバのサンプルではないですが、情報ありがとうございました。

APモードのHTTPサーバのPOST通信は、難しいようです。

0 Likes
lock attach
Attachments are accessible only for community members.

Usually, POST method is used to send data to the server. HTTP server for AP mode is not that difficult. Attached is a modified version of  snip.http_server_sent_events but the example does not have POST method because it's usually the other way around.

0 Likes

Thank you very much.

I would like to know how to receive the HTTP data POSTed from the client with the callback function (WiFi_ap_http_receive_callback). Please let me know if you understand.

<Japanese>

ありがとうございます。

クライアントからPOSTされたHTTPデータを、コールバック関数(WiFi_ap_http_receive_callback)で受信する方法を知りたいのですが、わかりましたら教えてください。

0 Likes

If you don't have it, please answer without it.

<Japanese>

無ければ、無いで回答をお願いします。

0 Likes

I am not sure if I understand your requirement correctly. Kindly correct me if I am wrong.

  1. WICED device is configured as a softAP and http_server is hosted over softAP interface
  2. A http client like google chrome sends a PUT request
  3. WICED device, working as a http server receives the request and parses the request and dumps the payload on serial terminal or send some other event as a response to client.
0 Likes

Thank you very much.

I think that data is set in the message body for both POST and PUT, but I can receive the data.

Can the received data be received with "uint8_t ** data"?

◆ Example

static wiced_result_t WiFi_ap_http_rcv_callback (wiced_http_response_stream_t * stream, uint8_t ** data, uint16_t * data_length)

<Japanese>

ありがとうございます。

POSTもPUTも、メッセージボディにデータが設定されると思いますが、データは受信できるのですね。

受信データは、「uint8_t** data」で受信できますか。

0 Likes

I am not sure if we understand each other correctly. It would be helpful if you can clearly define the requirement in steps as I have mentioned before.

WiFi_ap_http_rcv_callback is something that you might have written or used from somewhere. I have no insight in what it does. I can only speak about the WICED Studio http_server_sent_events example which uses the SSE and wiced_http_response_stream_t in that example. You can notice the implementation of send_event if that helps. Essentially wiced_http_response_stream_t encompasses wiced_tcp_stream_t data structure where the payload can be found in tx_packet_data ptr and if I am to guess by the way your api is constructed it might be fetching tx_packet_data and put into data (data type matching is the basis of my assumption)

From the sample (http_server_sent_events.c.zip), it seems possible to receive by "wiced_http_response_stream_t".

I wasn't looking at the samples properly.

Thank you very much.

<Japanese>

サンプル(http_server_sent_events.c.zip)から、「wiced_http_response_stream_t」による受信でできそうです。

サンプルをきちんと見ていませんでした。

ありがとうございました。

0 Likes