Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不穿格子衫的农民
TencentOS Tiny
提交
d7e5aa4d
T
TencentOS Tiny
项目概览
不穿格子衫的农民
/
TencentOS Tiny
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TencentOS Tiny
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d7e5aa4d
编写于
8月 10, 2020
作者:
M
mculover666
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update ec20 driver
上级
87364169
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
95 addition
and
29 deletion
+95
-29
devices/ec20/ec20.c
devices/ec20/ec20.c
+95
-29
未找到文件。
devices/ec20/ec20.c
浏览文件 @
d7e5aa4d
/**
/*----------------------------------------------------------------------------
* @brief Quectel EC20 LTGE Cat4 Module
* Tencent is pleased to support the open source community by making TencentOS
* @author Mculover666 <2412828003@qq.com>
* available.
* @date 2020/05/07
*
* @changelog
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
2020/05/21 Mculover666 Change recv mode is Direct Push Mode
* If you have downloaded a copy of the TencentOS binary from Tencent, please
*/
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "ec20.h"
#include "ec20.h"
#include "tos_at.h"
#include "tos_at.h"
...
@@ -15,6 +24,16 @@
...
@@ -15,6 +24,16 @@
#include <stdbool.h>
#include <stdbool.h>
#include <ctype.h>
#include <ctype.h>
typedef
struct
ip_addr_st
{
uint8_t
seg1
;
uint8_t
seg2
;
uint8_t
seg3
;
uint8_t
seg4
;
}
ip_addr_t
;
static
ip_addr_t
domain_parser_addr
=
{
0
};
k_sem_t
domain_parser_sem
;
static
int
ec20_echo_close
(
void
)
static
int
ec20_echo_close
(
void
)
{
{
at_echo_t
echo
;
at_echo_t
echo
;
...
@@ -341,31 +360,20 @@ static int ec20_close(int id)
...
@@ -341,31 +360,20 @@ static int ec20_close(int id)
static
int
ec20_parse_domain
(
const
char
*
host_name
,
char
*
host_ip
,
size_t
host_ip_len
)
static
int
ec20_parse_domain
(
const
char
*
host_name
,
char
*
host_ip
,
size_t
host_ip_len
)
{
{
char
*
str
;
at_echo_t
echo
;
at_echo_t
echo
;
char
echo_buffer
[
128
];
char
echo_buffer
[
128
];
tos_sem_create_max
(
&
domain_parser_sem
,
0
,
1
);
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
tos_at_cmd_exec
(
&
echo
,
2000
,
"AT+QIDNSGIP=1,
\"
%s
\"\r\n
"
,
host_name
);
tos_at_cmd_exec
(
&
echo
,
2000
,
"AT+QIDNSGIP=1,
\"
%s
\"\r\n
"
,
host_name
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
{
return
-
1
;
return
-
1
;
}
}
/*
tos_sem_pend
(
&
domain_parser_sem
,
TOS_TIME_FOREVER
);
+QIURC: "dnsgip",0,1,600
snprintf
(
host_ip
,
host_ip_len
,
"%d.%d.%d.%d"
,
domain_parser_addr
.
seg1
,
domain_parser_addr
.
seg2
,
domain_parser_addr
.
seg3
,
domain_parser_addr
.
seg4
);
+QIURC: "dnsgip","xxx.xxx.xxx"
*/
int
seg1
,
seg2
,
seg3
,
seg4
;
str
=
strstr
(
echo
.
buffer
,
"dnsgip"
);
*
str
=
'0'
;
str
=
strstr
(
echo
.
buffer
,
"dnsgip"
);
str
+=
strlen
(
"dnsgip
\"
,
\"
"
);
sscanf
(
str
,
"%d.%d.%d.%d"
,
&
seg1
,
&
seg2
,
&
seg3
,
&
seg4
);
snprintf
(
host_ip
,
host_ip_len
,
"%d.%d.%d.%d"
,
seg1
,
seg2
,
seg3
,
seg4
);
host_ip
[
host_ip_len
-
1
]
=
'\0'
;
host_ip
[
host_ip_len
-
1
]
=
'\0'
;
printf
(
"GOT IP: %s
\n
"
,
host_ip
);
printf
(
"GOT IP: %s
\n
"
,
host_ip
);
...
@@ -384,11 +392,6 @@ __STATIC__ void ec20_incoming_data_process(void)
...
@@ -384,11 +392,6 @@ __STATIC__ void ec20_incoming_data_process(void)
<data content>
<data content>
*/
*/
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
return
;
}
while
(
1
)
while
(
1
)
{
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
...
@@ -439,8 +442,71 @@ __STATIC__ void ec20_incoming_data_process(void)
...
@@ -439,8 +442,71 @@ __STATIC__ void ec20_incoming_data_process(void)
return
;
return
;
}
}
__STATIC__
void
ec20_domain_data_process
(
void
)
{
uint8_t
data
;
/*
+QIURC: "dnsgip",0,1,600
+QIURC: "dnsgip","xxx.xxx.xxx.xxx"
*/
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'0'
)
{
return
;
}
if
(
data
==
'\"'
)
{
/* start parser domain */
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'.'
)
{
break
;
}
domain_parser_addr
.
seg1
=
domain_parser_addr
.
seg1
*
10
+
(
data
-
'0'
);
}
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'.'
)
{
break
;
}
domain_parser_addr
.
seg2
=
domain_parser_addr
.
seg2
*
10
+
(
data
-
'0'
);
}
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'.'
)
{
break
;
}
domain_parser_addr
.
seg3
=
domain_parser_addr
.
seg3
*
10
+
(
data
-
'0'
);
}
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'\"'
)
{
break
;
}
domain_parser_addr
.
seg4
=
domain_parser_addr
.
seg4
*
10
+
(
data
-
'0'
);
}
tos_sem_post
(
&
domain_parser_sem
);
}
return
;
}
at_event_t
ec20_at_event
[]
=
{
at_event_t
ec20_at_event
[]
=
{
{
"+QIURC:
\"
recv
\"
"
,
ec20_incoming_data_process
},
{
"+QIURC:
\"
recv
\"
,"
,
ec20_incoming_data_process
},
{
"+QIURC:
\"
dnsgip
\"
,"
,
ec20_domain_data_process
},
};
};
sal_module_t
sal_module_ec20
=
{
sal_module_t
sal_module_ec20
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录