How to use http_client or https_client to send a post message to my web server?

Hello!

threw away the Sparkfun board and replaced it with nRF9151DK board; I'm hoping to get it work now, after trying for year.

I'm using SDK 2.6.1 and 2.8.0; the default is SDK 2.8.0.

My setup:
Updated Windows 11.
Onomondo SIM.

built https_client from sample and it worked; but, when changed the URL to "">https://ptsv3.com," it stopped working, although the idea is to send an HTTP(S) post message to my web server, which includes path and the receiver PHP program.

did not include the build log or code because could not post it; perhaps the post was too large, but serial terminal image

Also, which library should use to remove these errors?

*- error: unknown type name 'u32t'
*- error: unknown type name 'u8t'

With kind regards

Parents
  • I guess, "HTTPS_HOSTNAME" doesn't support a "path" element as you used ("https://" + HTTPS_HOSTNAME + "/t/mypts123/post/"). I didn't test it on my own, but I guess, if you add a "HTTPS_PATH" ("/t/mypts123/post/") as separate definition and use both in "HTTP_HEAD", the "getaddrinfo" with a pure "HTTPS_HOSTNAME" ("ptsv3.com") may have a chance to work.

  • Thanks for the information. Where can I see the whole header parameters? I added this:

    #define HTTP_HEAD   \
                "HEAD / HTTP/1.1\r\n"   \
                "Host: " CONFIG_HTTPS_HOSTNAME ":" HTTPS_PORT "\r\n"    \
                "Connection: close\r\n\r\n"     \
                "HTTPS_PATH: /t/mypts123/post"
    It is Ok to set HTTPS_PATH: os it is HTTPS_PATH, where can I see it?
    Are the following rows useful at all?

                "Content-type: text/plain\r\n"  \
                "Content-Length: 14"
                {"Hello word"}
    Also, the program https_client employs 89% Flash, and need to integrate GNSS to provide geolocation while posting a message
    don't require SSL at all.
    What am i doing wrong?
    with kind regards
    Francisco
  • There is no http-header "HTTPS_PATH: /t/mypts123/post", so that doesn't work.

    Replace:

    "Host: " HTTPS_HOSTNAME ":" HTTPS_PORT "\r\n"    \

    by

    #define HTTPS_HOSTNAME "ptsv3.com"

    #define HTTPS_PATH "/t/mypts123/post"

    "Host: " HTTPS_HOSTNAME ":" HTTPS_PORT HTTPS_PATH  "\r\n"    \

    edited:

    Just as background info:

    DNS uses hostnames, e.g. "ptsv3.com", but no URI as

    https://ptsv3.com/t/mypts123/post

    The sample only offers a very simple function, I'm not sure, if that is the right place to start for you.

    Anyway, I'm just an other user. Maybe you get better advice from someone else.  

  • Hello, Achim Kraus. value your assistance as user. 

    As I still have questions; I'm hoping Nordic engineer can help.

    Why do have to press the reset button to get some letters, or even rows of text? from the board?

    Say, in the attached image, the output text required three resets.

    How can include payload with the post message?

    With warm regards
    Francisco

  • Some more answers (still not complete):

    > the program https_client employs 89% Flash

    Build it with:

    west build -b nrf9151dk/nrf9151/ns -p

    requires about 11% of the flash.

    >  the output text required three resets.

    Sometimes the modem requires some time for tasks. e.g. searching a network may require up to 1-2 minutes.

    > don't require SSL at all.

    That mainly means, not using "IPPROTO_TLS_1_2" and instead "IPPROTO_TCP". Also change the port form 443 to 80 an don't call "tls_setup".

    There is also a http-client in zephyr, see http_client . That may be easier, but I'm not common with it, I'm using CoAP/DTLS 1.2 CID.

  • Hello, Achim Kraus.

    Thank you so much; I really appreciate your help! I Will try with http_client

Reply Children
No Data
Related