This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-CC3235SF: WIFI-HTTP code does not work in STA mode

Part Number: LAUNCHXL-CC3235SF
Other Parts Discussed in Thread: CC3235SF

Tool/software:

WIFI-HTTP code does not work in STA mode .I'm putting it in STA mode. The device gets the ip address. For example, it gets the address 192.168.10.145. I set the dns setting of the connected network to 192.168.10.1, but when I type mysimplelink.net in the browser, it cannot connect to this address.

  • Hi,

    No. It cannot work by this way at STA mode. There is no way how CC32xx can affect other DNS server. This is not issue of CC32xx but it comes from principles how TCP/IP networks and DNS works. At STA mode you can use mDNS to with .local addresses, but your client computer needs to support mDNS. Windows, Linux, Android and iOS have different approach to mDNS. That means that there is no universal approach.

    Jan

  • Hello; My problem is actually this. You know the ready-made WIFI-HTTP code, right? In this code, mysimplelink.net is connected to the address and many operations can be done.
    The problem is that the code works very successfully in AP mode. but when I put the code in STA mode, I cannot connect when I type mysimplelink.net address in the browser. I can connect when I type the ip address that the device receives. What is the cause of this problem and what is the solution I am actually looking for this 

    Code: 

    void * httpserverThread(void *pvParameters)
    {
    mq_attr attr;
    int32_t msgqRetVal;
    int32_t retc = 0;
    pthread_t spawn_thread = (pthread_t) NULL;
    pthread_attr_t pAttrs_spawn;
    struct sched_param priParam;

    SPI_init();

    /* NWP günlüğü */
    MAP_PinTypeUART(PIN_62, PIN_MODE_1);
    /* Configure the Display module for UART output */
    Display_init();

    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
    /* Failed to open Display module */
    while(1);
    }

    /* Initialize SlNetSock layer with CC3x20 interface */
    /* We're using priority 5 */
    SlNetIf_init(0);
    SlNetIf_add(SLNETIF_ID_1, "CC32xx", (const SlNetIf_Config_t *)&SlNetIfConfigWifi, /*priority*/ 5);
    SlNetSock_init(0);
    SlNetUtil_init(0);

    /* Create the sl_Task */
    pthread_attr_init(&pAttrs_spawn);
    priParam.sched_priority = SPAWN_TASK_PRIORITY;
    retc = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
    retc |= pthread_attr_setstacksize(&pAttrs_spawn, TASKSTACKSIZE);
    retc |= pthread_attr_setdetachstate(&pAttrs_spawn, PTHREAD_CREATE_DETACHED);

    retc = pthread_create(&spawn_thread, &pAttrs_spawn, sl_Task, NULL);

    if (retc < 0)
    {
    /* Handle Error */
    Display_printf(display, 0, 0, "[Http server task] Could not create SimpleLink Task");
    while(1);
    }

    retc = sl_Start(0, 0, 0);
    if (retc < 0)
    {
    /* Handle Error */
    Display_printf(display, 0, 0, "[Http server task] sl_Start failed");
    while(1);
    }

    setScanPolicy();
    /* Output device information to the UART terminal */
    DisplayBanner(APPLICATION_NAME, APPLICATION_VERSION);

    retc = sl_Stop(SL_STOP_TIMEOUT);
    if (retc < 0)
    {
    /* Handle Error */
    Display_printf(display, 0, 0, "[Http server task] sl_Stop failed");
    while(1);
    }

    /* Switch off red LED */
    GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF);

    /* Reset The state of the machine */
    Network_IF_ResetMCUStateMachine();

    /* Start the driver */
    // retc = Network_IF_InitDriver(ROLE_AP);
    retc = Network_IF_InitDriver(ROLE_STA);
    if (retc < 0) {
    Display_printf(display, 0, 0, "[Http server task] Failed to start SimpleLink Device", retc);
    }

    // Set the device to use DHCP mode in STA mode
    int ret = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE, SL_NETCFG_ADDR_DHCP, 0, 0);
    if (ret < 0) {
    Display_printf(display, 0, 0, "Failed to set DHCP mode");
    while (1);
    }

    // Connect to Wi-Fi (STA mode)
    SlWlanSecParams_t secParams = {0};
    secParams.Key = (signed char *)SECURITY_KEY;
    secParams.KeyLen = strlen(SECURITY_KEY);
    secParams.Type = SECURITY_TYPE;

    retc = Network_IF_ConnectAP(SSID_NAME, secParams);
    if (retc < 0) {
    Display_printf(display, 0, 0, "[Http server task] Failed to connect to AP");
    while(1);
    }

    // Wait for IP acquisition before starting the HTTP server
    if (IS_IP_ACQUIRED(g_ulStatus)) {
    Display_printf(display, 0, 0, "[Http server task] IP acquired, starting HTTP server.");

    // Retrieve and print SSID (Network Name)
    Display_printf(display, 0, 0, "Connected to network: %s", g_ucConnectionSSID);

    // Retrieve IP address
    unsigned long ipAddr, subMask, gateway, dns;
    int32_t retc = Network_IF_IpConfigGet(&ipAddr, &subMask, &gateway, &dns);
    if (retc < 0) {
    Display_printf(display, 0, 0, "Failed to get IP configuration");
    } else {
    // Print IP Address
    Display_printf(display, 0, 0, "IP Address: %d.%d.%d.%d",
    SL_IPV4_BYTE(ipAddr, 3), SL_IPV4_BYTE(ipAddr, 2), SL_IPV4_BYTE(ipAddr, 1), SL_IPV4_BYTE(ipAddr, 0));

    if (dns != 0 && dns != 0xFFFFFFFF) { // Ensure valid DNS
    Display_printf(display, 0, 0, "DNS Address: %d.%d.%d.%d",
    SL_IPV4_BYTE(dns, 3), SL_IPV4_BYTE(dns, 2), SL_IPV4_BYTE(dns, 1), SL_IPV4_BYTE(dns, 0));
    } else {
    Display_printf(display, 0, 0, "DNS Address not available or invalid");
    } }

    // Start the HTTP server after IP acquisition
    ConfigureHttpServer();
    } else {
    Display_printf(display, 0, 0, "[Http server task] Waiting for IP address...");
    while (!IS_IP_ACQUIRED(g_ulStatus)) {
    usleep(1000); // Wait until IP is acquired
    }

    // Retrieve and print SSID (Network Name)
    Display_printf(display, 0, 0, "Connected to network: %s", g_ucConnectionSSID);

    // Retrieve IP address
    unsigned long ipAddr, subMask, gateway, dns;
    int32_t retc = Network_IF_IpConfigGet(&ipAddr, &subMask, &gateway, &dns);
    if (retc < 0) {
    Display_printf(display, 0, 0, "Failed to get IP configuration");
    } else {
    // Print IP Address
    Display_printf(display, 0, 0, "IP Address: %d.%d.%d.%d",
    SL_IPV4_BYTE(ipAddr, 3), SL_IPV4_BYTE(ipAddr, 2), SL_IPV4_BYTE(ipAddr, 1), SL_IPV4_BYTE(ipAddr, 0));

    // Print DNS Address
    if (dns != 0 && dns != 0xFFFFFFFF) { // Ensure valid DNS
    Display_printf(display, 0, 0, "DNS Address: %d.%d.%d.%d",
    SL_IPV4_BYTE(dns, 3), SL_IPV4_BYTE(dns, 2), SL_IPV4_BYTE(dns, 1), SL_IPV4_BYTE(dns, 0));
    } else {
    Display_printf(display, 0, 0, "DNS Address not available or invalid");
    } }

    // Start the HTTP server after IP acquisition
    ConfigureHttpServer();
    }

    if (retc < 0)
    {
    Display_printf(display, 0, 0, "[Http server task] Failed to start SimpleLink Device", retc);
    }

    /* initializes mailbox for http messages */
    attr.mq_maxmsg = 1; /* queue size */
    attr.mq_msgsize = sizeof( SlNetAppRequest_t* ); /* Size of message */
    httpserverMQueue = mq_open("httpserver msg q", O_CREAT, 0, &attr);
    if(httpserverMQueue == NULL)
    {
    Display_printf(display, 0, 0, "[Http server task] could not create msg queue");
    while (1);
    }

    retc = ConfigureHttpServer();
    if (retc < 0)
    {
    /* Handle Error */
    Display_printf(display, 0, 0, "[Http server task] Configure HTTP server failed");
    while(1);
    }
    // Start time synchronization

    initHttpserverDB();

  • Hi,

    There is NO solution at CC32xx side. Only way is change DNS record inside your DNS server.

    Other option can be usage of mDNS, but this is not a universal solution. Because differs between OS and version of OS (for example some version of Windows 10 use for resolving .local address LLMNR protocol some version mDNS, etc.)

    Jan

  • There is NO solution at CC32xx side. Only way is change DNS record inside your DNS server.

    What do you mean by this? You mean change my DNS address. For example, if my cc3235sf device has an ip address of 192.168.10.145, what should the DNS be. are you talking about something like this?

  • Hi,

    This comes from basic principles how computer networks works. CC32xx device or other network device cannot do with this anything.

    How DNS server at your network works and is configured depends on your network infrastructure. Sometimes is DHCP server configured to use dhcp hostname (Option 12) as hostname for DNS server. For example if client hostname is "my_CC3235" than infrastructure can create DNS record like "my_CC3235.xxxxx". But this depends on your infrastructure not a CC32xx.

    Jan

  • First of all, thank you for your answers.
    However, I am interested in what the solution is rather than what my problem is.
    I need to solve these problems. I need to use this wifi-http structure. How can I use this structure by solving this problem. what is the solution?
    I can send you the codes with the codes related to the codes.
    Please let's find a solution to my problem.

  • When I type mysimplelink.net/example.html in AP mode, the html page opens and works properly. I can't do the same in sta mode. When I type 192.168.10.145/example.html in STA mode, the html page opens. I don't understand where I'm going wrong. actually the code shows that it works in sta mode. the only problem is that I want to access the html page in this way mysimplelink.net/example.html without entering the ip address 

  • Hi,

    Solution of this issue is at settings of network infrastructure not a CC32xx side. No line of code at CC32xx can fully satisfy this issue. Only way what you can try to use is using mDNS and use resolving of address xxx.local. But this will not work at many cases.

    mDNS features of CC32xx are described at SWRU455 chapter 10.

    Jan

  • First of all, thank you for your answers.
    However, I am interested in what the solution is rather than what my problem is.
    I need to solve these problems. I need to use this wifi-http structure. How can I use this structure by solving this problem. what is the solution?
    I can send you the codes with the codes related to the codes.
    Please let's find a solution to my problem.

  • Hi,

    Asking same question multiple times will not solve your issue. Only thing you can try is to use mDNS. But you will find that this way is far from ideal.

    Maybe you should read some course of TCP/IP network and DNS (my recommendation is book Tcp/Ip from Heather Osterloh). Than you will realise, why your question have no easy solution.

    Jan

  • I can't switch to TCP/IP protocol. I cannot implement this solution right now. I need to solve this with the current terms and conditions. thanks for your suggestion.
    Sometimes it's hard to understand why TI officials don't take care of the problems.
    So I thank you for that.

  • Hi,

    HTTP is just protocol above TCP/IP. That mean with HTTP you are using TCP/IP.

    • As I said solution is at network infrastructure side not a CC32xx side.
    • Only thing what you can try at CC32xx is to use mDNS for resolving address like mysimplelink.local. But this will not work at all cases.
    • It may to exist other approach when you send IP address to some your Cloud server and show IP address at that server according your external IP, but this is not great as well.
    • You can create own client application for finding your device at network and opening web-browser with such IP. Many manufacturers of network devices use this way.
    • Or you can public your own RFC standard, wait for approved and implemented into wide range operating systems and web browser. This can take 8-10 years.

    TI care about problems o their customer. But you are asking for solution of thing which does not have solution at present time. Not only for TI but for other manufacturers.

    Please answer me for this question. You buy IP camera and you connect it into network. IP camera use DHCP. You want to open webpages of this camera. How you can do this? How do you determine IP address of IP camera?

    Jan

  • Greetings;
    First of all, there is no rule that everyone will have your experience or knowledge. Therefore, here is someone who has just started working with TI. And you are giving solution suggestions as if the person in front of you has mastered everything.
    I don't want something that doesn't exist. I don't believe that there is no solution to this situation. Because when you type the ip address that the device receives into the web browser, the system works. However, when you try to connect with the domain name, the system does not work, I do not think there is no solution to this.
    You are giving me very broad suggestions. However, I am not someone who knows everything here. If I was someone who knew everything, I would not ask questions anyway.
    Therefore, I expect you to answer more specifically and through code or specific examples. You are not obliged to do this, of course.

  • Hi,

    I think if you want develop network (WiFi) device is mandatory to have at least basic knowledge how computer networks works.

    As I said. You can try mDNS, maybe it will work at your case. Or you can create native application (for Windows, Android, iOS) which will find your device at network and open device webpages as use many network devices manufacturers. Or if your device have LCD display show IP address at LCD or show QR code with IP address. But as I said many times there is no standard and universal solution when device is connected into network based on DNS. If you don't believe me, just find few manuals of different network devices and do your own research.

    Jan

  • What I don't understand is why there is a DNS problem in STA mode when the device works properly in AP mode.  

  • Hi,

    At AP mode is DNS served by DNS server at CC32xx. But at STA mode is used DNS server at your network. And your DNS server does not have idea about your CC32xx device. Some DHCP servers can configure DNS server at your network by hostname reported from CC32xx (field URN at CC32xx settings) when DHCP is used. But this depends on your network infrastructure.

    Jan