EC20的某些版本,如EC20CEFILG-128-SGNS是具有GPS定位功能的,参照手册有对应的AT指令集可以读取,通过at_exec_cmd可以很方便的执行。
#include <rtthread.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include <at.h>
static void show_information()
{
at_response_t resp = RT_NULL;
resp = at_create_resp(512, 0, rt_tick_from_millisecond(5000));
at_exec_cmd(resp, "AT+QGPSGNMEA="RMC"");
LOG_D("resp->line_counts:%d", resp->line_counts);
for (int i = 0; i < (int) resp->line_counts; i++)
{
LOG_D("%s", at_resp_get_line(resp, i + 1));
}
at_delete_resp(resp);
}
int main(void)
{
int count = 1;
int i = 0; //用于保存是否已经开启GPS
LOG_D("Hello RT-Thread!");
rt_thread_mdelay(5000);
LOG_D("Hello RT-Thread!");
at_response_t resp = RT_NULL;
resp = at_create_resp(512, 0, rt_tick_from_millisecond(5000));
at_exec_cmd(resp, "AT+QGPS?");
LOG_D("resp->line_counts:%d", resp->line_counts);
LOG_D("at_resp_get_line_by_kw:%s", at_resp_get_line_by_kw(resp, "+QGPS:"));
at_resp_parse_line_args_by_kw(resp, "+QGPS:", "+QGPS:%d", &i);
if (i == 0)
{
at_exec_cmd(resp, "AT+QGPS=1");
}
LOG_D("at_resp_parse_line_args_by_kw:%d", i);
for (int i = 0; i < (int) resp->line_counts; i++)
{
LOG_D("%s", at_resp_get_line(resp, i + 1));
}
at_exec_cmd(resp, "AT+QGPSCFG=?");
at_delete_resp(resp);
while (count++)
{
show_information();
rt_thread_mdelay(1000);
}
return RT_EOK;
}
最后
以上就是想人陪夏天最近收集整理的关于rt-thread AT设备EC20获取GNSS信息的全部内容,更多相关rt-thread内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复