We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I need to send a UDP package with this function( netUDP_Send )
https://www.keil.com/pack/doc/mw/Network/html/group__udp__user__api.html#ga7a82db98b82300e5fd03ce1b7afb6cba
But I don't have remote IP and Port number. I have added a new variable to get remote IP and Port number but it shows me an error.
NET_ADDR4 addrUDP;uint32_t udp_cb_func (int32_t socket, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { addrUDP=addr; return 0;}
How can I send a UDP package?
I really appreciate your response.
I have set my device to 192.168.1.100 and it is activated in my network( it responds to ping command). But I cant received anything. Here is my code
int main (void){ netInitialize (); Eth(); while(1){ Sendd(); osDelay(100); } } NET_ADDR4 addrUDP={ NET_ADDR_IP4, 5022, 192, 168, 1, 10 }; uint32_t udp_cb_func (int32_t socket, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { //addrUDP=addr; return 0; } void Eth(){ uint8_t mac_addr [NET_ADDR_ETH_LEN]; uint8_t ip4_addr [NET_ADDR_IP4_LEN]; netIP_aton ("192.168.1.100", NET_ADDR_IP4, ip4_addr); while (netARP_GetMAC (NET_IF_CLASS_ETH | 0, ip4_addr, mac_addr) != netOK) { netARP_CacheIP (NET_IF_CLASS_ETH | 0, ip4_addr, netARP_CacheTemporaryIP); osDelay (1000); } socket = netUDP_GetSocket(udp_cb_func); if (socket >= 0) { netUDP_Open(socket, 2050); } void Sendd(void){ sprintf(buf,"H%d",1); sendbuf = netUDP_GetBuffer (2); State=netUDP_Send (socket,(NET_ADDR *)&addrUDP, buf,2); if(State!=netOK){ netUDP_Close(socket); socket = netUDP_GetSocket(udp_cb_func); if (socket >= 0) { netUDP_Open(socket, 2050); netUDP_SetOption (socket, netUDP_OptionTTL, 2); } } }
I need to do two work.
1) Obtaining remote IP address without inserting into my code (192.168.1.10)
2) Sending a simple UDP package.