Why failed to set apn?

I used 9160 to develop a project for the customer. According to my design, an apn needs to be set before connecting to the NB-iot network. However, when I used at command to set it, the result was unsuccessful, but when I used at command to read it, the parameters were correct. so, what has happend?

static NB_APN_PARAMENT nb_apn_table[] = 
{
	//china mobile
	{	
		"46004",
		"cmnbiot2"
	},
	//arkessa
	{
		"90128", 
		"arkessalp.com",
	},
};

void SetNetWorkApn(u8_t *imsi_buf)
{
	u32_t i;
	u8_t tmpbuf[256] = {0};

	for(i=0;i<ARRAY_SIZE(nb_apn_table);i++)
	{
		if(strncmp(imsi_buf, nb_apn_table[i].plmn, strlen(nb_apn_table[i].plmn)) == 0)
		{
			u8_t cmdbuf[128] = {0};
			
			sprintf(cmdbuf, "AT+CGDCONT=0,\"IP\",\"%s\"", nb_apn_table[i].apn);
			LOGD("cmdbuf:%s", cmdbuf); 
			if(at_cmd_write(cmdbuf, tmpbuf, sizeof(tmpbuf), NULL) != 0)
			{
				LOGD("set apn fail!");
			}

			break;
		}
	}

	if(at_cmd_write(CMD_GET_APN, tmpbuf, sizeof(tmpbuf), NULL) == 0)
	{
		LOGD("apn:%s", tmpbuf); 
	}
}
  

Parents Reply Children
Related