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

nef9160 IMEI

Dear Sir,

Moving to zephyr new installation 1.4.99  

The code of getting the IMEI number no longer works.

Modem firmware is mfw_nrf9160_1.2.3

reply_buf_len = at_exec_reply("AT+CGSN=1", 9, &reply_buf[0], 30);

Am I missing something ?.

Is there any example ?.

 

Please Advise

Parents Reply Children
  • Hi.

    in Main I issue the command   GetIMEI();

    Attached some code 

    #include "at.h"
    
    #include <zephyr.h>
    #include <stdio.h>
    #include <string.h>
    //#include <zephyr.h>
    #include <nrf_socket.h>
    #include <net/socket.h>
    
    
    int at_exec(char * at_command, int at_command_strlen) 
    {
    	int  at_sock;
    	int  bytes_sent;
    	int  bytes_received;
    	char buf[2];
    	int ret = 0;
    
    	at_sock = socket(AF_LTE, 0, NPROTO_AT);
    	if (at_sock < 0)
    	{
    		printk("[%s:%d] ERROR: AT commands socket error.\n", __func__, __LINE__);
                    return -1;
    	}
    
    	bytes_sent = send(at_sock, at_command, at_command_strlen, 0);
    	
    	if (bytes_sent < 0)
    	{
    		close(at_sock);
    		return -1;
    	}
    		
    	do
    	{
    		bytes_received = recv(at_sock, buf, 2, 0);
    	} while (bytes_received == 0);
    	
    	if (memcmp(buf, "OK", 2) != 0)
    		ret = -1;
    	
    	close(at_sock);	
    	return ret;
    }
    
    /*
    	out_reply_str - an allocated string of length out_reply_str_len
    */
    int at_exec_reply(char * at_command, int at_command_strlen, char * out_reply_str, int out_reply_str_len) 
    {
    	int  at_sock;
    	int  bytes_sent;
    	int  bytes_received;
    	int ret = 0;
    
    	at_sock = socket(AF_LTE, 0, NPROTO_AT);
    	if (at_sock < 0)
    	{
    		printk("[%s:%d] ERROR: AT commands socket error.\n", __func__, __LINE__);
    		return -1;
    	}
    
    	bytes_sent = send(at_sock, at_command, at_command_strlen, 0);
    	
    	if (bytes_sent < 0)
    	{
    		close(at_sock);
    		return -1;
    	}
    		
    	do
    	{
    		bytes_received = recv(at_sock, out_reply_str, out_reply_str_len, 0);
    	} while (bytes_received == 0);
    	ret = bytes_received;
    	
    	close(at_sock);	
    	return ret;
    }
    
    
    

    The line at_sock = socket(AF_LTE, 0, NPROTO_AT);   in at.c return false.

    Is there another way to get the IMEI number within the code ?.

    Bye.

Related