This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

program hangs up at blocking_recv function sometimes

Environment
- Mac
- nrf tag; 1.1.0
- modem fw: 1.1.0
- DK 0.8.5
- debugging by SEGGER RTT
The program polls SMS for a certain time and if SMS is received, it reads the messages.

When the message is read by blocking_recv, the program hangs up. I coded this program referring to this source:
https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/simple_at/src/main.c
Also "(sms_notif_fd_s.revents & POLLIN) == POLLIN" sometimes gets true although I don't send SMS to the device.
This symptom did not happen with v1.1.0 of nrf_tag and v1.1.0 of modem

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int blocking_recv(int fd, u8_t *buf, u32_t size, u32_t flags)
{
int err;
do {
err = recv(fd, buf, size, flags);
} while (err < 0 && errno == EAGAIN);
return err;
}
void main(void)
{
sms_notif_fd = socket(AF_LTE, 0, NPROTO_AT);
sms_notif_fd_s.fd = sms_notif_fd;
sms_notif_fd_s.events = POLLIN;
/* MQTT connect, publish, and disconnect here */
while (1) {
err = poll(&sms_notif_fd_s, 1, K_SECONDS(60));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Why does this happen and how can I solve this?
Should I close and open a socket at a certain interval?

I erase previous program by "nrfjprog -e" everytime I flash a new one, and delete an old build folder before building a new program.

Thanks!

---- update -----

when blocking_recv is stuck, err = -1 and errno = 11 are always reported.