当前位置:网站首页>4G module designed by charging pile obtains signal strength and quality
4G module designed by charging pile obtains signal strength and quality
2022-07-03 09:59:00 【Wukong is so timid】
int dx_get_lte_signalQuality(void)
{
// char cmd[64] = {0};
//char result[512] = {0};
int ret = -1;
char *pcTmp = NULL;
char sigal[32] = {0};
char *pcSigal = sigal;
int rssi = 0;
int index = 0;
unsigned char *cmd = at_tx_buffer;
unsigned char *result = at_rx_buffer;
unsigned char result_len = 0;
// snprintf(cmd, sizeof(cmd), "AT+CSQ");
memset(at_tx_buffer,0,UART2_TX_BUFFER_LEN);
memset(at_rx_buffer,0,UART2_RX_BUFFER_LEN);
snprintf((char*)at_tx_buffer,UART2_TX_BUFFER_LEN, AT_CSQ);
ret = AT_cmd(cmd, strlen((const char*)cmd), result, &result_len);
/*
AT+CSQ
+CSQ: 19,99
OK
*/
// printf("AT+CSQ:\n%s\n", result);
printf("\n result =%s\n", result);
if (ret || !strlen((const char*)result) || !strstr((const char*)result, "OK"))
{
ret = 0;
goto out ;
}
pcTmp = strchr((const char*)result, ' ');
if (pcTmp)
{
pcTmp++;
while(*pcTmp != ',' && *pcTmp >= '0' && *pcTmp <= '9' && *pcTmp != '\0')
{
*pcSigal++ = *pcTmp++;
}
}
else
{
ret = 0;
goto out ;
}
*pcSigal = '\0';
index = atoi(sigal);
if (index < 0 || index >= 32)
{
ret = 0;
return 0;
}
rssi = -113 + (index * 2);
printf("index:%d rssi:%d\n", index, rssi);
if (rssi >= -80)
{
// return 4;
ret =4;
return ret;
}
else if (-90 <= rssi && -80 > rssi)
{
// return 3;
ret =3;
return ret;
}
else if (-105 <= rssi && -90 > rssi)
{
// return 2;
ret =2;
return ret;
}
else if (-105 > rssi)
{
ret =1;
return ret;
}
out:
// memset(at_tx_buffer,0,UART2_TX_BUFFER_LEN);
// memset(at_rx_buffer,0,UART2_RX_BUFFER_LEN);
return ret;
}
边栏推荐
- Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
- Working mode of 80C51 Serial Port
- MYSQL数据库底层基础专栏
- UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
- There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
- A lottery like scissors, stone and cloth (C language)
- Education is a pass and ticket. With it, you can step into a higher-level environment
- UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
- UCI and data multiplexing are transmitted on Pusch - Part I
- IDEA远程断点调试jar包项目
猜你喜欢
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction
Of course, the most widely used 8-bit single chip microcomputer is also the single chip microcomputer that beginners are most easy to learn
Interruption system of 51 single chip microcomputer
Oracle database SQL statement execution plan, statement tracking and optimization instance
uniapp 实现微信小程序全局分享及自定义分享按钮样式
[graduation successful] [1] - tour [Student Management Information System]
[untitled] proteus simulation of traffic lights based on 89C51 Single Chip Microcomputer
openEuler kernel 技术分享 - 第1期 - kdump 基本原理、使用及案例介绍
Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from
随机推荐
C language enumeration type
El table X-axis direction (horizontal) scroll bar slides to the right by default
Successful graduation [3]- blog system update...
2. Elment UI date selector formatting problem
All processes of top ten management in project management
STM32 running lantern experiment - library function version
UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
CEF download, compile project
(2)接口中新增的方法
Synchronization control between tasks
(1) 什么是Lambda表达式
Schematic diagram and connection method of six pin self-locking switch
IDEA远程断点调试jar包项目
Education is a pass and ticket. With it, you can step into a higher-level environment
STM32 serial port usart1 routine
STM32 general timer output PWM control steering gear
Eight working modes of stm32gpio and chip naming rules
UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
Project cost management__ Cost management technology__ Article 7 completion performance index (tcpi)
51 MCU tmod and timer configuration