require websocket and https combine example

Hi,

I am using SDK v2.6.1.

Is there any course available on DevAcademy for WebSockets?

For WebSocket i take reference of v2.6.1/zephyr/samples/net/sockets/websocket_client,

when i try to give wifi credential using wifi connect -s <ssid> -k 1 -p <password> then i have got wifi: command not found so require to give wifi credential?or how we are able to see WebSocket reference code output,

I need an example that merges WebSocket and HTTPS. Could you also provide feedback on how to merge both into a single code?

  • Hi,

    In my previous reply, I shared code where I successfully connected to Wi-Fi and established internet access. I was also able to connect to the HTTP host, but I encountered issues when trying to connect to the WebSocket host.

    also i disable the http portion from the code and try to connect with WebSocket host but i am not able to connect with it.

    Could you please review my code and provide feedback to help me resolve the WebSocket connection issue?

  • Hi,

    Can you send your project so that I can try to reproduce the error?

    Best regards,
    Dejan

  • Hi,

    I have tried to replicate your issue, but I was unsuccessful. I have built your application on Windows 10 using nrf7002dk board and built for nrf7002dk_nrf5340_cpuapp in NCS v2.6.1. I have changed only wifi_ssid and wifi_password to reflect my ssid and password.
    Here is my log

    *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
    [00:00:02.040,771] <inf> wifi_mgmt_ext: Connection requested
    [00:00:02.041,534] <inf> Lesson5_Exercise1: Connecting to Wi-Fi
    [00:00:04.604,827] <inf> wifi_mgmt_ext: Connection requested
    [00:00:07.173,156] <inf> wifi_mgmt_ext: Connection requested
    [00:00:09.741,699] <inf> wifi_mgmt_ext: Connection requested


    Are there any other changes to the project required for it to be built successfully?

    Best regards,
    Dejan

  • HI,

    I hope so you change ssid and password in below functon,also i used WIFI_SECURITY_TYPE_PSK for security

    void set_wifi_credentials_struct()
    {

    char *wifi_ssid = "realme";
    char *wifi_password = "Chirag@1527";

    wifi_cred.header.type = WIFI_SECURITY_TYPE_PSK;
    memset(wifi_cred.header.bssid, 0, sizeof(wifi_cred.header.bssid));
    wifi_cred.header.flags = 0;
    //wifi_cred.header.channel = WIFI_CHANNEL_ANY;
    //wifi_cred.header.timeout = 10;

    wifi_cred.header.ssid_len = strlen(wifi_ssid);
    memcpy(wifi_cred.header.ssid, wifi_ssid, wifi_cred.header.ssid_len);
    wifi_cred.password_len = strlen(wifi_password);
    memcpy(wifi_cred.password, wifi_password, wifi_cred.password_len);

    int ret = wifi_credentials_set_personal_struct(&wifi_cred);

    if (ret != 0) {
    LOG_ERR("Failed to set credentials, err: %d", ret);
    }
    }
Related