当前位置:网站首页>4G module IMEI of charging pile design
4G module IMEI of charging pile design
2022-07-03 09:59:00 【Wukong is so timid】
void dx_get_lte_imei(void)
{
// char cmd[64] = {0};
//char result[512] = {0};
int ret = -1;
char *pcTmp = NULL;
char *pcOut = g_imei;
unsigned char *cmd = at_tx_buffer;
unsigned char *result = at_rx_buffer;
unsigned char result_len = 0;
printf("g_imei:%s\n", g_imei);
if (dx_check_imei(g_imei))
{
// snprintf(imei, imei_len, "%s", g_imei);
printf("imei haved get ,is %s\r\n",g_imei);
return;
}
memset(at_tx_buffer,0,UART2_TX_BUFFER_LEN);
memset((char*)at_rx_buffer,0,UART2_RX_BUFFER_LEN);
snprintf((char*)at_tx_buffer,UART2_TX_BUFFER_LEN, "%s",AT_GSN);
ret = AT_cmd(cmd, strlen((const char*)cmd), result,&result_len);
/*
AT+GSN
865860040521701
OK
*/
printf("ret=%d \r\n", ret);
printf("strstr(result, OK=0x%08x \r\n", (unsigned int)strstr((const char*)result, "OK"));
printf("strstr(result, GSN=0x%08x \r\n", (unsigned int)strstr((const char*)result, "GSN"));
/* Filter out wrong data */
#if 0
// if ((ret ==0) && strstr((const char*)result, "OK") && !strstr((const char*)result, "GSN"))
if ((ret ==0) && strstr((const char*)result, "OK") )
{
// memset(result, 0, sizeof(result));
// ret = AT_cmd(cmd, strlen(cmd), result, sizeof(result));
printf("GSN read ok data %s----\n", result);
printf("AT+GSN:\n%s\n", result);
// goto out ;
}
#endif
if (ret ==0)
{
if(strstr((const char*)result, "OK") ==NULL )
{
// memset(result, 0, sizeof(result));
// ret = AT_cmd(cmd, strlen(cmd), result, sizeof(result));
printf("GSN read error data1 %s----\n", result);
printf("AT+GSN:\n%s\n", result);
goto out ;
}
#if 0
else if(!strstr((const char*)result, "GSN"))
{
// memset(result, 0, sizeof(result));
// ret = AT_cmd(cmd, strlen(cmd), result, sizeof(result));
printf("GSN read error data2 %s----\n", result);
printf("AT+GSN:\n%s\n", result);
goto out ;
}
#endif
}
else
{
printf("AT+GSN fail\n");
goto out ;
}
/*
if (ret || !strlen(result) || strstr(result, "OK"))
{
snprintf(g_imei, sizeof(g_imei), "000000000000000");
return;
}
*/
printf("\n result =%s\n", result);
pcTmp = strchr((const char*)result, '\n');
if (pcTmp)
{
pcTmp++;
while(*pcTmp != '\r' && *pcTmp != '\n' && *pcTmp != '\0' && (*pcTmp >= '0' && *pcTmp <= '9'))
{
//printf("*pcTmp=%c\r\n",*pcTmp);
*pcOut++ = *pcTmp++;
}
}
if (strlen(g_imei) < 15)
{
snprintf(g_imei, sizeof(g_imei), "000000000000000");
goto out ;
}
else
{
//memset(g_imei, 0, sizeof(g_imei));
// snprintf(g_imei, sizeof(g_imei), "%s", imei);
printf("g_imei=%s\r\n",g_imei);
}
out:
// memset(at_tx_buffer,0,UART2_TX_BUFFER_LEN);
// memset(at_rx_buffer,0,UART2_RX_BUFFER_LEN);
return;
}
边栏推荐
猜你喜欢
要選擇那種語言為單片機編寫程序呢
没有多少人能够最终把自己的兴趣带到大学毕业上
The cyclic shift of PUCCH in NR channel is generated by MATLAB
03 FastJson 解决循环引用
2. Elment UI date selector formatting problem
Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction
2021-10-27
UCI and data multiplexing are transmitted on Pusch (Part VI) -- LDPC coding
嵌入式系统没有特别明确的定义
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
随机推荐
UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
PRACH --- originator
没有多少人能够最终把自己的兴趣带到大学毕业上
UCI and data multiplexing are transmitted on Pusch - Part I
一个可执行的二进制文件包含的不仅仅是机器指令
Design of charging pile mqtt transplantation based on 4G EC20 module
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
2021-01-03
Programming ideas are more important than anything, not more than who can use several functions, but more than the understanding of the program
Mysql database underlying foundation column
Raspberry pie installation SciPy
单片机现在可谓是铺天盖地,种类繁多,让开发者们应接不暇
el-table X轴方向(横向)滚动条默认滑到右边
万字手撕七大排序(代码+动图演示)
For new students, if you have no contact with single-chip microcomputer, it is recommended to get started with 51 single-chip microcomputer
2021-10-28
There is no specific definition of embedded system
STM32 external interrupt experiment
Schematic diagram and connection method of six pin self-locking switch
01仿B站项目业务架构