Hi,
I'm try to set up a UDP server on a nRF9151dk, and send data from a remote pc to the devkit. I have tested my sim and networking works correctly, I am able to use coap_client on the board to make requests to a coap server.
void udp_thread(void) { printk("Starting UDP server\n"); int fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { printk("socket"); } struct sockaddr_in sin, cin; socklen_t cin_len = sizeof(cin); inet_pton(AF_INET, "100.xx.xx.1", &sin.sin_addr); // my sim static ip, also tried INADDR_ANY sin.sin_family = AF_INET; sin.sin_port = htons(4242); if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { printk("bind"); } printk("Listening on UDP port %d\n", 4242); while (true) { ssize_t len = recvfrom(fd, buf, BUF_SIZE, 0, &cin, &cin_len); if (len < 0) { printk("recv"); } printk("Received %ld bytes\n", (long)len); } } int main(void) { modem_init(); k_sleep(K_SECONDS(15)); udp_thread(); }
This function is straight from one of the examples, on the client side I use python to send a message over UDP.
Something like this:
from socket import * s = socket(AF_INET, SOCK_DGRAM) s.sendto(b'hello', ("100.xx.xx.1", 4242))
Any ideas what the issue could be? The relevant config:
# Main stack and heap size CONFIG_MAIN_STACK_SIZE=4096 CONFIG_HEAP_MEM_POOL_SIZE=30000 # RTT based logging CONFIG_LOG=y CONFIG_LOG_MODE_IMMEDIATE=y CONFIG_USE_SEGGER_RTT=y CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096 CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN=360 # LTE, modem & soft-SIM configuration CONFIG_NRF_MODEM_LIB=y CONFIG_MODEM_INFO=y CONFIG_MODEM_KEY_MGMT=y CONFIG_LTE_LINK_CONTROL=y CONFIG_LTE_LC_PSM_MODULE=y CONFIG_LTE_LC_EDRX_MODULE=y CONFIG_SOFTSIM=y CONFIG_SOFTSIM_LOG_LEVEL_INF=y # Networking CONFIG_NETWORKING=y CONFIG_NET_NATIVE=n CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_OFFLOAD=y CONFIG_NET_SOCKETS_POSIX_NAMES=y CONFIG_COAP=y
Probably something dumb on my end, but I can't seem to spot it...
Edit: Forgot to mention that my issue is I do not receive any data on the devkit (acting as UDP server). I do not use use any encryption either.
Thanks!