Dear,
I am using THINGY91 for proving my concept, I put THINGY91 in the freezer - to adapt to the temperature.
I am using NB_iot of telia (norway)
My problem is: sometimes my thingy91 lost the network (the freezer is so good :( ), and couldn't send the data to my webserver
I tried to change my state-machine: THINGY91 will check the network and reconnect if it couldn't find the network
1. check the network:
/**************************************************************************************************** *name: NETWORK CHECK *todo: find status of the network *return: connect/disconnect: *mccmnc * ****************************************************************************************************/ void NETW_CHECK(char *mccmnc ) { const char *ATCOPS="AT+COPS?"; int at_socket_fd = socket(AF_LTE, 0, NPROTO_AT); // printk("LTE socket is: %d \n",at_socket_fd); if (at_socket_fd < 0) { printk("Socket err: %d, errno: %d\r\n", at_socket_fd, errno); } /* * find MNC and MCC */ int bytes_written0 = send(at_socket_fd, ATCOPS, strlen(ATCOPS), 0); if (bytes_written0 > 0) { int r_bytes = blocking_recv(at_socket_fd, recv_buf, sizeof(recv_buf), MSG_DONTWAIT); if (r_bytes > 0) { //printk("%s", recv_buf); char splitStringsmcc[10][10]; split_string_ltepos(recv_buf,splitStringsmcc); memcpy(mccmnc,splitStringsmcc[1],sizeof(splitStringsmcc[1])); printk("MCC&MNC: %s\n\r",mccmnc); } } (void)close(at_socket_fd); }
I will return MCCMNC,"24202" for telia, and if it couldnt find the network, I will try to reconnect:
void reconnect_nw(void){ int err; printk("ReConnecting to LTE network. "); printk("This may take several minutes.\n"); //ui_led_set_pattern(UI_LTE_CONNECTING); err = lte_lc_init_and_connect(); if (err) { printk("LTE link could not be established.\n"); } printk("Connected to LTE network\n"); }
But, this function lte_lc_init_and_connect() didnt work, it just returned "LTE link could not be established.;
I am using the config file as the same with : master/applications/asset_tracker/prj_nrf9160_pca20035ns.conf, it will contain "CONFIG_LTE_AUTO_INIT_AND_CONNECT=n"
Could you plz help me, I need a solution how can thingy91 can automatically re-connect the network if the network is disconnected.
Thanks so much
Best Regards,
Hoang Nguyen