Using a AF_INET UDP socket on the nrf9160 I will get ENOMEM when I send a bunch of datagrams over the socket. I understand how there can be a limited number of buffers for sending, but shouldn't sendto() block waiting for one to become available?
The sample below illustrates the problem. In my test I didn't have a server running to receive the datagrams, if it matters. This may be related to my other ticket: https://devzone.nordicsemi.com/f/nordic-q-a/52437/nrf_poll-may-be-consuming-data-when-not-supposed-to-on-nrf9160
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CONFIG_BSD_LIBRARY=y
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=n
CONFIG_NET_UDP=n
CONFIG_NET_TCP=n
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
# Our CPU has hardware stack limit checking, and it needs to be large
CONFIG_HW_STACK_PROTECTION=y
CONFIG_MAIN_STACK_SIZE=4096
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <zephyr.h>
#include <stdio.h>
#include <string.h>
//#include <nrf_socket.h>
#include <net/socket.h>
#define NRF_HTONL(val) ((((uint32_t) (val) & 0xff000000) >> 24) | \
(((uint32_t) (val) & 0x00ff0000) >> 8) | \
(((uint32_t) (val) & 0x0000ff00) << 8) | \
(((uint32_t) (val) & 0x000000ff) << 24))
#define IPADDR(a,b,c,d) (((u32_t)a << 24) | ((u32_t)b << 16) | ((u32_t)c << 8) | (u32_t)d)
static struct sockaddr_in remote_addr;
void lteon( void )
{
int nread;
char buff[100];
int sock = socket(AF_LTE, 0, NPROTO_AT);
send( sock, "AT+CEREG=2", 10, 0 );