Yanko Sosa

Yanko Sosa

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: UDP broadcast #27151

    Yanko Sosa
    Keymaster

    Hi Eli,
    You’d have to set the socket address (in the case for IPv4) to “255.255.255.255”. You can do this by using the NetApp_SetSockAddr() API after opening the socket and passing this API a pointer to a variable of type NET_IPv4_ADDR that contains the broadcast address (‘server_addr’ in the following example):

        
    #define  TX_BUF_SIZE          256u
    #define  UDP_SERVER_PORT    10001u
    
    CPU_BOOLEAN UDP_Client_Pseudocode(void)
    {
        NET_SOCK_ADDR             server_sock_addr;    
        NET_IPv4_ADDR             server_addr;
        NET_SOCK_ID               sock;
        NET_ERR                   err;
        CPU_CHAR                  tx_buf[TX_BUF_SIZE];
        NET_SOCK_DATA_SIZE        tx_rem;
        OS_ERR                    os_err;
    
        NetASCII_Str_to_IP("255.255.255.255",
                           &server_addr,
                            sizeof(server_addr),
                           &err);
    
        sock = NetSock_Open(NET_SOCK_PROTOCOL_FAMILY_IP_V4,
                            NET_SOCK_TYPE_DATAGRAM,
                            NET_SOCK_PROTOCOL_UDP,
                           &err);
    
        NetApp_SetSockAddr(        &server_sock_addr,
                                    NET_SOCK_ADDR_FAMILY_IP_V4,
                                    UDP_SERVER_PORT,
                           (void *)&server_addr,
                                    NET_IPv4_ADDR_SIZE,
                                   &err);
    
    //optionally you could bind 'sock' here to a specific local port and/or interface number
    
        tx_rem = TX_BUF_SIZE;
        p_buf  = tx_buf;
        do {
            tx_size = NetSock_TxDataTo(                  sock,
                                                         tx_buf,
                                                         tx_rem,
                                                         NET_SOCK_FLAG_NONE,
                                       (NET_SOCK_ADDR *)&server_sock_addr,
                                                         NET_SOCK_ADDR_SIZE,
                                                        &err);
            switch (err) {
                case NET_SOCK_ERR_NONE:
                     tx_rem -= tx_size;
                    *(CPU_INT08U *)p_buf  += tx_size;
                     break;
    
                case NET_ERR_FAULT_LOCK_ACQUIRE:
                case NET_ERR_TX:
                case NET_ERR_IF_LINK_DOWN:
                     OS_TimeDly(1u, OS_OPT_TIME_DLY, &os_err);
                     break;
    
                default:
                     NetSock_Close(sock, &err);
                     return (DEF_FAIL);
                }
                if (tx_rem == 0u) {
                    break;
                }
            } while (1u);
    
            NetSock_Close(sock, &err);
            return (DEF_OK);
    }
    in reply to: HTTPs_ReqBodyRxHook never called #24980

    Yanko Sosa
    Keymaster

    Hi Janusz,
    Is there a reason why you’re using HTTPs_RespBodySetParamNoBody() for a file upload use case? To answer your question, we just send a HTTP 200 status response when this API is called.

    in reply to: mc/HTTP and Angular #24172

    Yanko Sosa
    Keymaster

    Hi Janusz,
    Yes, it’s possible to use Angular. You’d just have to handle the HTTP request(s) in the server hook functions.

Viewing 3 posts - 1 through 3 (of 3 total)

View the complete site map

x
Loading...