Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不穿格子衫的农民
TencentOS Tiny
提交
122fa9fd
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 搜索 >>
提交
122fa9fd
编写于
8月 13, 2020
作者:
M
mculover666
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for multi sal devices concurrently
上级
772d714a
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
588 addition
and
356 deletion
+588
-356
board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c
.../TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c
+9
-1
board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/usart.c
board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/usart.c
+3
-2
board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx
...EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx
+19
-23
board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx
...VB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx
+5
-0
devices/ec20/ec20.c
devices/ec20/ec20.c
+117
-57
devices/esp8266/esp8266.c
devices/esp8266/esp8266.c
+111
-48
devices/esp8266/esp8266.h
devices/esp8266/esp8266.h
+3
-0
examples/tcp_through_module/tcp_through_module.c
examples/tcp_through_module/tcp_through_module.c
+5
-3
net/at/include/tos_at.h
net/at/include/tos_at.h
+24
-25
net/at/src/tos_at.c
net/at/src/tos_at.c
+159
-161
net/sal_module_wrapper/sal_module_wrapper.c
net/sal_module_wrapper/sal_module_wrapper.c
+88
-27
net/sal_module_wrapper/sal_module_wrapper.h
net/sal_module_wrapper/sal_module_wrapper.h
+45
-9
未找到文件。
board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c
浏览文件 @
122fa9fd
...
...
@@ -298,9 +298,17 @@ void LPUART1_IRQHandler(void)
void
HAL_UART_RxCpltCallback
(
UART_HandleTypeDef
*
huart
)
{
extern
uint8_t
data
;
extern
at_agent_t
esp8266_at_agent
;
extern
uint8_t
ec20_data
;
extern
at_agent_t
ec20_at_agent
;
if
(
huart
->
Instance
==
LPUART1
)
{
HAL_UART_Receive_IT
(
&
hlpuart1
,
&
data
,
1
);
tos_at_uart_input_byte
(
data
);
tos_at_uart_input_byte
(
&
esp8266_at_agent
,
data
);
}
else
if
(
huart
->
Instance
==
USART3
)
{
HAL_UART_Receive_IT
(
&
huart3
,
&
ec20_data
,
1
);
tos_at_uart_input_byte
(
&
ec20_at_agent
,
ec20_data
);
}
}
/* USER CODE END 1 */
...
...
board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/usart.c
浏览文件 @
122fa9fd
...
...
@@ -23,6 +23,7 @@
/* USER CODE BEGIN 0 */
uint8_t
data
;
uint8_t
msg
;
uint8_t
ec20_data
;
/* USER CODE END 0 */
UART_HandleTypeDef
hlpuart1
;
...
...
@@ -99,7 +100,7 @@ void MX_USART3_UART_Init(void)
{
huart3
.
Instance
=
USART3
;
huart3
.
Init
.
BaudRate
=
96
00
;
huart3
.
Init
.
BaudRate
=
1152
00
;
huart3
.
Init
.
WordLength
=
UART_WORDLENGTH_8B
;
huart3
.
Init
.
StopBits
=
UART_STOPBITS_1
;
huart3
.
Init
.
Parity
=
UART_PARITY_NONE
;
...
...
@@ -112,7 +113,7 @@ void MX_USART3_UART_Init(void)
{
Error_Handler
();
}
HAL_UART_Receive_IT
(
&
huart3
,
&
msg
,
1
);
//(uint8_t *)aRxBuffer, 1);
HAL_UART_Receive_IT
(
&
huart3
,
&
ec20_data
,
1
);
//(uint8_t *)aRxBuffer, 1);
}
void
HAL_UART_MspInit
(
UART_HandleTypeDef
*
uartHandle
)
...
...
board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx
浏览文件 @
122fa9fd
...
...
@@ -154,22 +154,6 @@
<Type>
0
</Type>
<LineNumber>
69
</LineNumber>
<EnabledFlag>
1
</EnabledFlag>
<Address>
134234708
</Address>
<ByteObject>
0
</ByteObject>
<HtxType>
0
</HtxType>
<ManyObjects>
0
</ManyObjects>
<SizeOfObject>
0
</SizeOfObject>
<BreakByAccess>
0
</BreakByAccess>
<BreakIfRCount>
1
</BreakIfRCount>
<Filename>
..\..\..\..\examples\tcp_through_module\tcp_through_module.c
</Filename>
<ExecCommand></ExecCommand>
<Expression>
\\TencentOS_tiny\../../../../examples/tcp_through_module/tcp_through_module.c\69
</Expression>
</Bp>
<Bp>
<Number>
1
</Number>
<Type>
0
</Type>
<LineNumber>
66
</LineNumber>
<EnabledFlag>
1
</EnabledFlag>
<Address>
0
</Address>
<ByteObject>
0
</ByteObject>
<HtxType>
0
</HtxType>
...
...
@@ -303,7 +287,7 @@
<Group>
<GroupName>
Application/User
</GroupName>
<tvExp>
0
</tvExp>
<tvExp>
1
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<cbSel>
0
</cbSel>
<RteFlg>
0
</RteFlg>
...
...
@@ -1203,7 +1187,7 @@
<Group>
<GroupName>
at
</GroupName>
<tvExp>
0
</tvExp>
<tvExp>
1
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<cbSel>
0
</cbSel>
<RteFlg>
0
</RteFlg>
...
...
@@ -1223,7 +1207,7 @@
<Group>
<GroupName>
devices
</GroupName>
<tvExp>
0
</tvExp>
<tvExp>
1
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<cbSel>
0
</cbSel>
<RteFlg>
0
</RteFlg>
...
...
@@ -1239,17 +1223,29 @@
<RteFlg>
0
</RteFlg>
<bShared>
0
</bShared>
</File>
<File>
<GroupNumber>
12
</GroupNumber>
<FileNumber>
73
</FileNumber>
<FileType>
1
</FileType>
<tvExp>
0
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<bDave2>
0
</bDave2>
<PathWithFileName>
..\..\..\..\devices\ec20\ec20.c
</PathWithFileName>
<FilenameWithoutPath>
ec20.c
</FilenameWithoutPath>
<RteFlg>
0
</RteFlg>
<bShared>
0
</bShared>
</File>
</Group>
<Group>
<GroupName>
sal_module_wrapper
</GroupName>
<tvExp>
0
</tvExp>
<tvExp>
1
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<cbSel>
0
</cbSel>
<RteFlg>
0
</RteFlg>
<File>
<GroupNumber>
13
</GroupNumber>
<FileNumber>
7
3
</FileNumber>
<FileNumber>
7
4
</FileNumber>
<FileType>
1
</FileType>
<tvExp>
0
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
...
...
@@ -1263,13 +1259,13 @@
<Group>
<GroupName>
hal
</GroupName>
<tvExp>
0
</tvExp>
<tvExp>
1
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
<cbSel>
0
</cbSel>
<RteFlg>
0
</RteFlg>
<File>
<GroupNumber>
14
</GroupNumber>
<FileNumber>
7
4
</FileNumber>
<FileNumber>
7
5
</FileNumber>
<FileType>
1
</FileType>
<tvExp>
0
</tvExp>
<tvExpOptDlg>
0
</tvExpOptDlg>
...
...
board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx
浏览文件 @
122fa9fd
...
...
@@ -798,6 +798,11 @@
<FileType>
1
</FileType>
<FilePath>
..\..\..\..\devices\esp8266\esp8266.c
</FilePath>
</File>
<File>
<FileName>
ec20.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\..\..\devices\ec20\ec20.c
</FilePath>
</File>
</Files>
</Group>
<Group>
...
...
devices/ec20/ec20.c
浏览文件 @
122fa9fd
...
...
@@ -24,6 +24,8 @@
#include <stdbool.h>
#include <ctype.h>
static
k_stack_t
ec20_at_parser_task_stack
[
AT_PARSER_TASK_STACK_SIZE
];
typedef
struct
ip_addr_st
{
uint8_t
seg1
;
uint8_t
seg2
;
...
...
@@ -34,12 +36,15 @@ typedef struct ip_addr_st {
static
ip_addr_t
domain_parser_addr
=
{
0
};
k_sem_t
domain_parser_sem
;
at_agent_t
ec20_at_agent
;
#define AT_AGENT ((at_agent_t *)(&ec20_at_agent))
static
int
ec20_echo_close
(
void
)
{
at_echo_t
echo
;
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
NULL
);
tos_at_cmd_exec
(
&
echo
,
1000
,
"ATE0
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"ATE0
\r\n
"
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
)
{
return
0
;
...
...
@@ -56,7 +61,7 @@ static int ec20_sim_card_check(void)
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+CPIN?
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CPIN?
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
}
...
...
@@ -79,7 +84,7 @@ static int ec20_signal_quality_check(void)
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+CSQ
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CSQ
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
...
...
@@ -108,7 +113,7 @@ static int ec20_gsm_network_check(void)
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+CREG?
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CREG?
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
}
...
...
@@ -137,7 +142,7 @@ static int ec20_gprs_network_check(void)
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+CGREG?
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CGREG?
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
...
...
@@ -163,7 +168,7 @@ static int ec20_close_apn(void)
at_echo_t
echo
;
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
NULL
);
tos_at_cmd_exec
(
&
echo
,
3000
,
"AT+QIDEACT=1
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
3000
,
"AT+QIDEACT=1
\r\n
"
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
)
{
return
0
;
...
...
@@ -177,13 +182,13 @@ static int ec20_set_apn(void)
at_echo_t
echo
;
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
NULL
);
tos_at_cmd_exec
(
&
echo
,
300
,
"AT+QICSGP=1,1,
\"
CMNET
\"\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
300
,
"AT+QICSGP=1,1,
\"
CMNET
\"\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
}
tos_at_cmd_exec
_until
(
&
echo
,
3000
,
"AT+QIACT=1
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
3000
,
"AT+QIACT=1
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
...
...
@@ -246,29 +251,29 @@ static int ec20_connect(const char *ip, const char *port, sal_proto_t proto)
int
id
;
at_echo_t
echo
;
id
=
tos_at_channel_alloc
(
ip
,
port
);
id
=
tos_at_channel_alloc
(
AT_AGENT
,
ip
,
port
);
if
(
id
==
-
1
)
{
return
-
1
;
}
tos_at_cmd_exec
(
NULL
,
1000
,
"AT+QICLOSE=%d
\r\n
"
,
id
);
tos_at_cmd_exec
(
AT_AGENT
,
NULL
,
1000
,
"AT+QICLOSE=%d
\r\n
"
,
id
);
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"CONNECT OK"
);
tos_at_cmd_exec
(
&
echo
,
4000
,
"AT+QIOPEN=1,%d,
\"
%s
\"
,
\"
%s
\"
,%d,0,1
\r\n
"
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
4000
,
"AT+QIOPEN=1,%d,
\"
%s
\"
,
\"
%s
\"
,%d,0,1
\r\n
"
,
id
,
proto
==
TOS_SAL_PROTO_UDP
?
"UDP"
:
"TCP"
,
ip
,
atoi
(
port
));
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
)
{
return
id
;
}
tos_at_channel_free
(
id
);
tos_at_channel_free
(
AT_AGENT
,
id
);
return
-
1
;
}
static
int
ec20_recv_timeout
(
int
id
,
void
*
buf
,
size_t
len
,
uint32_t
timeout
)
{
return
tos_at_channel_read_timed
(
id
,
buf
,
len
,
timeout
);
return
tos_at_channel_read_timed
(
AT_AGENT
,
id
,
buf
,
len
,
timeout
);
}
static
int
ec20_recv
(
int
id
,
void
*
buf
,
size_t
len
)
...
...
@@ -280,41 +285,41 @@ int ec20_send(int id, const void *buf, size_t len)
{
at_echo_t
echo
;
if
(
!
tos_at_channel_is_working
(
id
))
{
if
(
!
tos_at_channel_is_working
(
AT_AGENT
,
id
))
{
return
-
1
;
}
if
(
tos_at_global_lock_pend
()
!=
0
)
if
(
tos_at_global_lock_pend
(
AT_AGENT
)
!=
0
)
{
return
-
1
;
}
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
">"
);
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+QISEND=%d,%d
\r\n
"
,
id
,
len
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+QISEND=%d,%d
\r\n
"
,
id
,
len
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
&&
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"SEND OK"
);
tos_at_raw_data_send_until
(
&
echo
,
10000
,
(
uint8_t
*
)
buf
,
len
);
tos_at_raw_data_send_until
(
AT_AGENT
,
&
echo
,
10000
,
(
uint8_t
*
)
buf
,
len
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
&&
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
len
;
}
int
ec20_recvfrom_timeout
(
int
id
,
void
*
buf
,
size_t
len
,
uint32_t
timeout
)
{
return
tos_at_channel_read_timed
(
id
,
buf
,
len
,
timeout
);
return
tos_at_channel_read_timed
(
AT_AGENT
,
id
,
buf
,
len
,
timeout
);
}
int
ec20_recvfrom
(
int
id
,
void
*
buf
,
size_t
len
)
...
...
@@ -326,46 +331,46 @@ int ec20_sendto(int id, char *ip, char *port, const void *buf, size_t len)
{
at_echo_t
echo
;
if
(
tos_at_global_lock_pend
()
!=
0
)
if
(
tos_at_global_lock_pend
(
AT_AGENT
)
!=
0
)
{
return
-
1
;
}
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
">"
);
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+QISEND=%d,%d
\r\n
"
,
id
,
len
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+QISEND=%d,%d
\r\n
"
,
id
,
len
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
&&
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"SEND OK"
);
tos_at_raw_data_send
(
&
echo
,
1000
,
(
uint8_t
*
)
buf
,
len
);
tos_at_raw_data_send
(
AT_AGENT
,
&
echo
,
1000
,
(
uint8_t
*
)
buf
,
len
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
&&
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
len
;
}
static
void
ec20_transparent_mode_exit
(
void
)
{
tos_at_cmd_exec
(
NULL
,
500
,
"+++"
);
tos_at_cmd_exec
(
AT_AGENT
,
NULL
,
500
,
"+++"
);
}
static
int
ec20_close
(
int
id
)
{
ec20_transparent_mode_exit
();
tos_at_cmd_exec
(
NULL
,
1000
,
"AT+QICLOSE=%d
\r\n
"
,
id
);
tos_at_cmd_exec
(
AT_AGENT
,
NULL
,
1000
,
"AT+QICLOSE=%d
\r\n
"
,
id
);
tos_at_channel_free
(
id
);
tos_at_channel_free
(
AT_AGENT
,
id
);
return
0
;
}
...
...
@@ -378,7 +383,7 @@ static int ec20_parse_domain(const char *host_name, char *host_ip, size_t host_i
tos_sem_create_max
(
&
domain_parser_sem
,
0
,
1
);
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
(
AT_AGENT
,
&
echo
,
2000
,
"AT+QIDNSGIP=1,
\"
%s
\"\r\n
"
,
host_name
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
...
...
@@ -393,6 +398,38 @@ static int ec20_parse_domain(const char *host_name, char *host_ip, size_t host_i
return
0
;
}
static
int
ec20_get_local_ip
(
char
*
ip
,
char
*
gw
,
char
*
mask
)
{
char
*
str
;
at_echo_t
echo
;
char
echo_buffer
[
100
];
int
seg1
,
seg2
,
seg3
,
seg4
;
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
2000
,
"AT+QIACT?
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
}
/*
+QIACT: 1,1,1,"10.186.107.143"
OK
*/
str
=
strstr
((
const
char
*
)
echo
.
buffer
,
"+QIACT"
);
if
(
!
str
)
{
return
-
1
;
}
sscanf
(
str
+
strlen
(
"+QIACT: 1,1,1,"
),
"
\"
%d.%d.%d.%d
\"
"
,
&
seg1
,
&
seg2
,
&
seg3
,
&
seg4
);
sprintf
(
ip
,
"%d.%d.%d.%d"
,
seg1
,
seg2
,
seg3
,
seg4
);
printf
(
"GOT EC20 MODULE IP: %s
\n
"
,
ip
);
/* ec20 has not provide the ability to query the subnet mask and gw ip address*/
return
0
;
}
__STATIC__
void
ec20_incoming_data_process
(
void
)
{
uint8_t
data
;
...
...
@@ -406,7 +443,7 @@ __STATIC__ void ec20_incoming_data_process(void)
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
...
...
@@ -420,7 +457,7 @@ __STATIC__ void ec20_incoming_data_process(void)
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
...
...
@@ -432,7 +469,7 @@ __STATIC__ void ec20_incoming_data_process(void)
data_len
=
data_len
*
10
+
(
data
-
'0'
);
}
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
...
...
@@ -440,11 +477,11 @@ __STATIC__ void ec20_incoming_data_process(void)
do
{
#define MIN(a, b) ((a) < (b) ? (a) : (b))
read_len
=
MIN
(
data_len
,
sizeof
(
buffer
));
if
(
tos_at_uart_read
(
buffer
,
read_len
)
!=
read_len
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
buffer
,
read_len
)
!=
read_len
)
{
return
;
}
if
(
tos_at_channel_write
(
channel_id
,
buffer
,
read_len
)
<=
0
)
{
if
(
tos_at_channel_write
(
AT_AGENT
,
channel_id
,
buffer
,
read_len
)
<=
0
)
{
return
;
}
...
...
@@ -464,7 +501,7 @@ __STATIC__ void ec20_domain_data_process(void)
+QIURC: "dnsgip","xxx.xxx.xxx.xxx"
*/
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
...
...
@@ -475,7 +512,7 @@ __STATIC__ void ec20_domain_data_process(void)
if
(
data
==
'\"'
)
{
/* start parser domain */
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'.'
)
{
...
...
@@ -484,7 +521,7 @@ __STATIC__ void ec20_domain_data_process(void)
domain_parser_addr
.
seg1
=
domain_parser_addr
.
seg1
*
10
+
(
data
-
'0'
);
}
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'.'
)
{
...
...
@@ -493,7 +530,7 @@ __STATIC__ void ec20_domain_data_process(void)
domain_parser_addr
.
seg2
=
domain_parser_addr
.
seg2
*
10
+
(
data
-
'0'
);
}
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'.'
)
{
...
...
@@ -502,7 +539,7 @@ __STATIC__ void ec20_domain_data_process(void)
domain_parser_addr
.
seg3
=
domain_parser_addr
.
seg3
*
10
+
(
data
-
'0'
);
}
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
'\"'
)
{
...
...
@@ -522,32 +559,49 @@ at_event_t ec20_at_event[] = {
};
sal_module_t
sal_module_ec20
=
{
.
init
=
ec20_init
,
.
connect
=
ec20_connect
,
.
send
=
ec20_send
,
.
recv_timeout
=
ec20_recv_timeout
,
.
recv
=
ec20_recv
,
.
sendto
=
ec20_sendto
,
.
recvfrom
=
ec20_recvfrom
,
.
recvfrom_timeout
=
ec20_recvfrom_timeout
,
.
close
=
ec20_close
,
.
parse_domain
=
ec20_parse_domain
,
.
sal_module_name
=
"ec20"
,
.
sal_module_ip
=
"0.0.0.0"
,
.
sal_module_type
=
TOS_SAL_MODULE_4G_LTE
,
.
sal_module_status
=
TOS_SAL_MODULE_UNAVAILABLE
,
.
init
=
ec20_init
,
.
connect
=
ec20_connect
,
.
send
=
ec20_send
,
.
recv_timeout
=
ec20_recv_timeout
,
.
recv
=
ec20_recv
,
.
sendto
=
ec20_sendto
,
.
recvfrom
=
ec20_recvfrom
,
.
recvfrom_timeout
=
ec20_recvfrom_timeout
,
.
close
=
ec20_close
,
.
parse_domain
=
ec20_parse_domain
,
};
int
ec20_sal_init
(
hal_uart_port_t
uart_port
)
{
if
(
tos_at_init
(
uart_port
,
ec20_at_event
,
sizeof
(
ec20_at_event
)
/
sizeof
(
ec20_at_event
[
0
]))
!=
0
)
{
char
ip
[
15
]
=
{
0
};
if
(
tos_at_init
(
AT_AGENT
,
ec20_at_parser_task_stack
,
uart_port
,
ec20_at_event
,
sizeof
(
ec20_at_event
)
/
sizeof
(
ec20_at_event
[
0
]))
!=
0
)
{
return
-
1
;
}
if
(
tos_sal_module_register
(
&
sal_module_ec20
)
!=
0
)
{
return
-
1
;
}
if
(
tos_sal_module_init
()
!=
0
)
{
if
(
ec20_init
()
!=
0
)
{
return
-
1
;
}
if
(
ec20_get_local_ip
(
ip
,
NULL
,
NULL
)
!=
0
)
{
return
-
1
;
}
tos_sal_module_set_local_ip
(
&
sal_module_ec20
,
ip
);
tos_sal_module_set_status
(
&
sal_module_ec20
,
TOS_SAL_MODULE_AVAILABLE
);
printf
(
"%s sal device register success
\r\n
"
,
sal_module_ec20
.
sal_module_name
);
return
0
;
}
...
...
@@ -559,9 +613,15 @@ int ec20_sal_deinit()
tos_sal_module_close
(
id
);
}
tos_sal_module_register_default
();
tos_sal_module_set_local_ip
(
&
sal_module_ec20
,
"0.0.0.0"
);
tos_sal_module_set_status
(
&
sal_module_ec20
,
TOS_SAL_MODULE_UNAVAILABLE
);
tos_sal_module_unregister
(
&
sal_module_ec20
);
tos_at_deinit
(
AT_AGENT
);
tos_at_deinit
(
);
printf
(
"%s sal device unregister success
\r\n
"
,
sal_module_ec20
.
sal_module_name
);
return
0
;
}
...
...
devices/esp8266/esp8266.c
浏览文件 @
122fa9fd
...
...
@@ -8,6 +8,12 @@
#define TOS_CFG_MODULE_SINGLE_LINK_EN 0u
at_agent_t
esp8266_at_agent
;
#define AT_AGENT ((at_agent_t *)(&esp8266_at_agent))
static
k_stack_t
esp8266_at_parser_task_stack
[
AT_PARSER_TASK_STACK_SIZE
];
static
int
esp8266_restore
(
void
)
{
int
try
=
0
;
...
...
@@ -15,7 +21,7 @@ static int esp8266_restore(void)
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
NULL
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
3000
,
"AT+RESTORE
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
3000
,
"AT+RESTORE
\r\n
"
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
)
{
return
0
;
}
...
...
@@ -28,7 +34,7 @@ static int esp8266_echo_close(void)
at_echo_t
echo
;
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
NULL
);
tos_at_cmd_exec
(
&
echo
,
1000
,
"ATE0
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"ATE0
\r\n
"
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
)
{
return
0
;
}
...
...
@@ -57,7 +63,7 @@ static int esp8266_net_mode_set(esp8266_net_mode_t mode)
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"no change"
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
1000
,
cmd
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
cmd
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
||
echo
.
status
==
AT_ECHO_STATUS_EXPECT
)
{
return
0
;
}
...
...
@@ -72,7 +78,7 @@ static int esp8266_send_mode_set(esp8266_send_mode_t mode)
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
NULL
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
1000
,
"AT+CIPMODE=%d
\r\n
"
,
mode
==
ESP8266_SEND_MODE_NORMAL
?
0
:
1
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPMODE=%d
\r\n
"
,
mode
==
ESP8266_SEND_MODE_NORMAL
?
0
:
1
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
)
{
return
0
;
}
...
...
@@ -87,7 +93,7 @@ static int esp8266_multilink_set(esp8266_multilink_state_t state)
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"link is builded"
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec
(
&
echo
,
500
,
"AT+CIPMUX=%d
\r\n
"
,
state
==
ESP8266_MULTILINK_STATE_ENABLE
?
1
:
0
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
500
,
"AT+CIPMUX=%d
\r\n
"
,
state
==
ESP8266_MULTILINK_STATE_ENABLE
?
1
:
0
);
if
(
echo
.
status
==
AT_ECHO_STATUS_OK
||
echo
.
status
==
AT_ECHO_STATUS_EXPECT
)
{
return
0
;
}
...
...
@@ -102,7 +108,7 @@ int esp8266_join_ap(const char *ssid, const char *pwd)
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"OK"
);
while
(
try
++
<
10
)
{
tos_at_cmd_exec_until
(
&
echo
,
15000
,
"AT+CWJAP=
\"
%s
\"
,
\"
%s
\"\r\n
"
,
ssid
,
pwd
);
tos_at_cmd_exec_until
(
AT_AGENT
,
&
echo
,
15000
,
"AT+CWJAP=
\"
%s
\"
,
\"
%s
\"\r\n
"
,
ssid
,
pwd
);
if
(
echo
.
status
==
AT_ECHO_STATUS_EXPECT
)
{
return
0
;
}
...
...
@@ -141,20 +147,20 @@ static int esp8266_connect(const char *ip, const char *port, sal_proto_t proto)
int
id
;
at_echo_t
echo
;
esp8266_reconnect_init
();
//
esp8266_reconnect_init();
id
=
tos_at_channel_alloc
(
ip
,
port
);
id
=
tos_at_channel_alloc
(
AT_AGENT
,
ip
,
port
);
if
(
id
==
-
1
)
{
return
-
1
;
}
tos_at_echo_create
(
&
echo
,
NULL
,
0
,
"OK"
);
#if TOS_CFG_MODULE_SINGLE_LINK_EN > 0u
tos_at_cmd_exec_until
(
&
echo
,
10000
,
tos_at_cmd_exec_until
(
AT_AGENT
,
&
echo
,
10000
,
"AT+CIPSTART=
\"
%s
\"
,
\"
%s
\"
,%s
\r\n
"
,
proto
==
TOS_SAL_PROTO_UDP
?
"UDP"
:
"TCP"
,
ip
,
port
);
#else
tos_at_cmd_exec_until
(
&
echo
,
10000
,
tos_at_cmd_exec_until
(
AT_AGENT
,
&
echo
,
10000
,
"AT+CIPSTART=%d,
\"
%s
\"
,
\"
%s
\"
,%s
\r\n
"
,
id
,
proto
==
TOS_SAL_PROTO_UDP
?
"UDP"
:
"TCP"
,
ip
,
port
);
#endif
...
...
@@ -162,14 +168,14 @@ static int esp8266_connect(const char *ip, const char *port, sal_proto_t proto)
return
id
;
}
tos_at_channel_free
(
id
);
tos_at_channel_free
(
AT_AGENT
,
id
);
return
-
1
;
}
static
int
esp8266_recv_timeout
(
int
id
,
void
*
buf
,
size_t
len
,
uint32_t
timeout
)
{
return
tos_at_channel_read_timed
(
id
,
buf
,
len
,
timeout
);
return
tos_at_channel_read_timed
(
AT_AGENT
,
id
,
buf
,
len
,
timeout
);
}
static
int
esp8266_recv
(
int
id
,
void
*
buf
,
size_t
len
)
...
...
@@ -192,29 +198,29 @@ static int esp8266_send(int id, const void *buf, size_t len)
at_echo_t
echo
;
char
echo_buffer
[
64
];
if
(
!
tos_at_channel_is_working
(
id
))
{
if
(
!
tos_at_channel_is_working
(
AT_AGENT
,
id
))
{
return
-
1
;
}
if
(
tos_at_global_lock_pend
()
!=
0
)
{
if
(
tos_at_global_lock_pend
(
AT_AGENT
)
!=
0
)
{
return
-
1
;
}
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
">"
);
#if TOS_CFG_MODULE_SINGLE_LINK_EN > 0u
tos_at_cmd_exec
(
&
echo
,
1000
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPSEND=%d
\r\n
"
,
len
);
#else
tos_at_cmd_exec
(
&
echo
,
1000
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPSEND=%d,%d
\r\n
"
,
id
,
len
);
#endif
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
&&
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
if
(
esp8266_is_link_broken
((
const
char
*
)
echo
.
buffer
))
{
tos_at_channel_set_broken
(
id
);
tos_at_channel_set_broken
(
AT_AGENT
,
id
);
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
...
...
@@ -224,17 +230,17 @@ static int esp8266_send(int id, const void *buf, size_t len)
ATTENTION: we should wait util "SEND OK" is echoed, otherwise the next
time we execute at command, the esp8266 maybe in a "busy s ..." state.
*/
tos_at_raw_data_send_until
(
&
echo
,
10000
,
(
uint8_t
*
)
buf
,
len
);
tos_at_raw_data_send_until
(
AT_AGENT
,
&
echo
,
10000
,
(
uint8_t
*
)
buf
,
len
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
if
(
esp8266_is_link_broken
((
const
char
*
)
echo
.
buffer
))
{
tos_at_channel_set_broken
(
id
);
tos_at_channel_set_broken
(
AT_AGENT
,
id
);
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
len
;
}
...
...
@@ -243,11 +249,11 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t
at_echo_t
echo
;
char
echo_buffer
[
64
];
if
(
!
tos_at_channel_is_working
(
id
))
{
if
(
!
tos_at_channel_is_working
(
AT_AGENT
,
id
))
{
return
-
1
;
}
if
(
tos_at_global_lock_pend
()
!=
0
)
{
if
(
tos_at_global_lock_pend
(
AT_AGENT
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -255,28 +261,28 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t
if
(
ip
&&
port
)
{
#if TOS_CFG_MODULE_SINGLE_LINK_EN > 0u
tos_at_cmd_exec
(
&
echo
,
1000
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPSEND=%d,
\"
%s
\"
,%s
\r\n
"
,
len
,
ip
,
port
);
#else
tos_at_cmd_exec
(
&
echo
,
1000
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPSEND=%d,%d,
\"
%s
\"
,%s
\r\n
"
,
id
,
len
,
ip
,
port
);
#endif
}
else
{
#if TOS_CFG_MODULE_SINGLE_LINK_EN > 0u
tos_at_cmd_exec
(
&
echo
,
1000
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPSEND=%d
\r\n
"
,
len
);
#else
tos_at_cmd_exec
(
&
echo
,
1000
,
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
1000
,
"AT+CIPSEND=%d,%d
\r\n
"
,
id
,
len
);
#endif
}
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
&&
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
if
(
esp8266_is_link_broken
((
const
char
*
)
echo
.
buffer
))
{
tos_at_channel_set_broken
(
id
);
tos_at_channel_set_broken
(
AT_AGENT
,
id
);
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
...
...
@@ -286,23 +292,23 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t
ATTENTION: we should wait util "SEND OK" is echoed, otherwise the next
time we execute at command, the esp8266 maybe in a "busy s ..." state.
*/
tos_at_raw_data_send_until
(
&
echo
,
10000
,
(
uint8_t
*
)
buf
,
len
);
tos_at_raw_data_send_until
(
AT_AGENT
,
&
echo
,
10000
,
(
uint8_t
*
)
buf
,
len
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_EXPECT
)
{
if
(
esp8266_is_link_broken
((
const
char
*
)
echo
.
buffer
))
{
tos_at_channel_set_broken
(
id
);
tos_at_channel_set_broken
(
AT_AGENT
,
id
);
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
-
1
;
}
tos_at_global_lock_post
();
tos_at_global_lock_post
(
AT_AGENT
);
return
len
;
}
static
int
esp8266_recvfrom_timeout
(
int
id
,
void
*
buf
,
size_t
len
,
uint32_t
timeout
)
{
return
tos_at_channel_read_timed
(
id
,
buf
,
len
,
timeout
);
return
tos_at_channel_read_timed
(
AT_AGENT
,
id
,
buf
,
len
,
timeout
);
}
static
int
esp8266_recvfrom
(
int
id
,
void
*
buf
,
size_t
len
)
...
...
@@ -313,11 +319,11 @@ static int esp8266_recvfrom(int id, void *buf, size_t len)
static
int
esp8266_close
(
int
id
)
{
#if TOS_CFG_MODULE_SINGLE_LINK_EN > 0u
tos_at_cmd_exec
(
NULL
,
1000
,
"AT+CIPCLOSE
\r\n
"
);
tos_at_cmd_exec
(
AT_AGENT
,
NULL
,
1000
,
"AT+CIPCLOSE
\r\n
"
);
#else
tos_at_cmd_exec
(
NULL
,
1000
,
"AT+CIPCLOSE=%d
\r\n
"
,
id
);
tos_at_cmd_exec
(
AT_AGENT
,
NULL
,
1000
,
"AT+CIPCLOSE=%d
\r\n
"
,
id
);
#endif
tos_at_channel_free
(
id
);
tos_at_channel_free
(
AT_AGENT
,
id
);
return
0
;
}
...
...
@@ -330,7 +336,7 @@ static int esp8266_parse_domain(const char *host_name, char *host_ip, size_t hos
esp8266_reconnect_init
();
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
tos_at_cmd_exec
(
&
echo
,
2000
,
"AT+CIPDOMAIN=
\"
%s
\"\r\n
"
,
host_name
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
2000
,
"AT+CIPDOMAIN=
\"
%s
\"\r\n
"
,
host_name
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
...
...
@@ -349,6 +355,37 @@ static int esp8266_parse_domain(const char *host_name, char *host_ip, size_t hos
return
0
;
}
static
int
esp8266_get_local_ip
(
char
*
ip
,
char
*
gw
,
char
*
mask
)
{
char
*
str
;
at_echo_t
echo
;
char
echo_buffer
[
100
];
int
seg1
,
seg2
,
seg3
,
seg4
;
tos_at_echo_create
(
&
echo
,
echo_buffer
,
sizeof
(
echo_buffer
),
NULL
);
tos_at_cmd_exec
(
AT_AGENT
,
&
echo
,
2000
,
"AT+CIFSR
\r\n
"
);
if
(
echo
.
status
!=
AT_ECHO_STATUS_OK
)
{
return
-
1
;
}
/*
+CIFSR:STAIP,<Station IP address>
+CIFSR:STAMAC,<Station MAC address>
*/
str
=
strstr
((
const
char
*
)
echo
.
buffer
,
"STAIP"
);
if
(
!
str
)
{
return
-
1
;
}
sscanf
(
str
+
strlen
(
"STAIP,"
),
"
\"
%d.%d.%d.%d
\"
"
,
&
seg1
,
&
seg2
,
&
seg3
,
&
seg4
);
sprintf
(
ip
,
"%d.%d.%d.%d"
,
seg1
,
seg2
,
seg3
,
seg4
);
printf
(
"GOT MODULE STA IP: %s
\n
"
,
ip
);
/* esp8266 has not provide the ability to query the subnet mask and gw ip address*/
return
0
;
}
static
int
esp8266_init
(
void
)
{
printf
(
"Init ESP8266 ...
\n
"
);
...
...
@@ -384,6 +421,10 @@ static int esp8266_init(void)
return
-
1
;
}
#endif
if
(
esp8266_join_ap
(
ESP8266_STA_SSID
,
ESP8266_STA_PASSWD
)
!=
0
)
{
return
-
1
;
}
printf
(
"Init ESP8266 Done
\n
"
);
return
0
;
...
...
@@ -405,7 +446,7 @@ __STATIC__ void esp8266_incoming_data_process(void)
*/
#if TOS_CFG_MODULE_SINGLE_LINK_EN == 0u
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
','
)
{
...
...
@@ -416,7 +457,7 @@ __STATIC__ void esp8266_incoming_data_process(void)
#endif
while
(
1
)
{
if
(
tos_at_uart_read
(
&
data
,
1
)
!=
1
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
&
data
,
1
)
!=
1
)
{
return
;
}
if
(
data
==
':'
)
{
...
...
@@ -428,11 +469,11 @@ __STATIC__ void esp8266_incoming_data_process(void)
do
{
#define MIN(a, b) ((a) < (b) ? (a) : (b))
read_len
=
MIN
(
data_len
,
sizeof
(
buffer
));
if
(
tos_at_uart_read
(
buffer
,
read_len
)
!=
read_len
)
{
if
(
tos_at_uart_read
(
AT_AGENT
,
buffer
,
read_len
)
!=
read_len
)
{
return
;
}
if
(
tos_at_channel_write
(
channel_id
,
buffer
,
read_len
)
<=
0
)
{
if
(
tos_at_channel_write
(
AT_AGENT
,
channel_id
,
buffer
,
read_len
)
<=
0
)
{
return
;
}
...
...
@@ -445,6 +486,10 @@ at_event_t esp8266_at_event[] = {
};
sal_module_t
sal_module_esp8266
=
{
.
sal_module_name
=
"esp8266"
,
.
sal_module_ip
=
"0.0.0.0"
,
.
sal_module_type
=
TOS_SAL_MODULE_WIFI
,
.
sal_module_status
=
TOS_SAL_MODULE_UNAVAILABLE
,
.
init
=
esp8266_init
,
.
connect
=
esp8266_connect
,
.
send
=
esp8266_send
,
...
...
@@ -459,8 +504,10 @@ sal_module_t sal_module_esp8266 = {
int
esp8266_sal_init
(
hal_uart_port_t
uart_port
)
{
if
(
tos_at_init
(
uart_port
,
esp8266_at_event
,
sizeof
(
esp8266_at_event
)
/
sizeof
(
esp8266_at_event
[
0
]))
!=
0
)
{
char
ip
[
15
]
=
{
0
};
if
(
tos_at_init
(
AT_AGENT
,
esp8266_at_parser_task_stack
,
uart_port
,
esp8266_at_event
,
sizeof
(
esp8266_at_event
)
/
sizeof
(
esp8266_at_event
[
0
]))
!=
0
)
{
return
-
1
;
}
...
...
@@ -468,9 +515,19 @@ int esp8266_sal_init(hal_uart_port_t uart_port)
return
-
1
;
}
if
(
tos_sal_module_init
()
!=
0
)
{
if
(
esp8266_init
()
!=
0
){
return
-
1
;
}
if
(
esp8266_get_local_ip
(
ip
,
NULL
,
NULL
)
!=
0
)
{
return
-
1
;
}
tos_sal_module_set_local_ip
(
&
sal_module_esp8266
,
ip
);
tos_sal_module_set_status
(
&
sal_module_esp8266
,
TOS_SAL_MODULE_AVAILABLE
);
printf
(
"%s sal device register success
\r\n
"
,
sal_module_esp8266
.
sal_module_name
);
return
0
;
}
...
...
@@ -483,9 +540,15 @@ int esp8266_sal_deinit()
tos_sal_module_close
(
id
);
}
tos_sal_module_register_default
();
tos_sal_module_set_local_ip
(
&
sal_module_esp8266
,
"0.0.0.0"
);
tos_sal_module_set_status
(
&
sal_module_esp8266
,
TOS_SAL_MODULE_UNAVAILABLE
);
tos_sal_module_unregister
(
&
sal_module_esp8266
);
tos_at_deinit
(
AT_AGENT
);
tos_at_deinit
(
);
printf
(
"%s sal device unregister success
\r\n
"
,
sal_module_esp8266
.
sal_module_name
);
return
0
;
}
...
...
devices/esp8266/esp8266.h
浏览文件 @
122fa9fd
...
...
@@ -20,6 +20,9 @@
#include "tos_hal.h"
#define ESP8266_STA_SSID "Mculover666"
#define ESP8266_STA_PASSWD "mculover666"
typedef
enum
esp8266_net_mode
{
ESP8266_NET_MODE_STA
,
ESP8266_NET_MODE_AP
,
...
...
examples/tcp_through_module/tcp_through_module.c
浏览文件 @
122fa9fd
...
...
@@ -5,7 +5,7 @@
#define USE_ESP8266
//#define USE_SIM800A
//#define USE_BC26
//
#define USE_EC20
#define USE_EC20
#ifdef USE_ESP8266
#include "esp8266.h"
...
...
@@ -85,15 +85,17 @@ void application_entry(void *arg)
{
#if defined(USE_ESP8266)
esp8266_sal_init
(
HAL_UART_PORT_0
);
esp8266_join_ap
(
"SheldonDai"
,
"srnr6x9xbhmb0"
);
#elif defined(USE_SIM800A)
sim800a_power_on
();
sim800a_sal_init
(
HAL_UART_PORT_2
);
#elif defined(USE_BC26)
bc26_sal_init
(
HAL_UART_PORT_2
);
#elif defined(USE_EC20)
ec20_sal_
deinit
(
HAL_PORT_0
);
ec20_sal_
init
(
HAL_UART_PORT_3
);
#endif
//tos_sal_module_set_default("esp8266");
tos_sal_module_set_default
(
"ec20"
);
socket_id_0
=
tos_sal_module_connect
(
"117.50.111.72"
,
"8080"
,
TOS_SAL_PROTO_TCP
);
if
(
socket_id_0
==
-
1
)
{
...
...
net/at/include/tos_at.h
浏览文件 @
122fa9fd
...
...
@@ -25,10 +25,10 @@
#define AT_AGENT_ECHO_FAIL "FAIL"
#define AT_AGENT_ECHO_ERROR "ERROR"
#define AT_DATA_CHANNEL_NUM
6
#define AT_DATA_CHANNEL_FIFO_BUFFER_SIZE (2048
+ 1024
)
#define AT_DATA_CHANNEL_NUM
2
#define AT_DATA_CHANNEL_FIFO_BUFFER_SIZE (2048)
#define AT_UART_RX_FIFO_BUFFER_SIZE (2048
+ 1024
)
#define AT_UART_RX_FIFO_BUFFER_SIZE (2048)
#define AT_RECV_CACHE_SIZE 2048
#define AT_CMD_BUFFER_SIZE 512
...
...
@@ -128,14 +128,13 @@ typedef struct at_agent_st {
uint8_t
*
uart_rx_fifo_buffer
;
}
at_agent_t
;
#define AT_AGENT ((at_agent_t *)(&at_agent))
/**
* @brief Write data to a channel.
* Write data to a channel with certain id.
*
* @attention None
*
* @param[in] at_agent at agent object
* @param[in] channel_id id of the channel.
* @param[in] buffer data buffer to write.
* @param[in] buffer_len length of the buffer.
...
...
@@ -144,7 +143,7 @@ typedef struct at_agent_st {
* @retval -1 write failed(error).
* @retval none -1 the number of bytes written.
*/
__API__
int
tos_at_channel_write
(
int
channel_id
,
uint8_t
*
buffer
,
size_t
buffer_len
);
__API__
int
tos_at_channel_write
(
at_agent_t
*
at_agent
,
int
channel_id
,
uint8_t
*
buffer
,
size_t
buffer_len
);
/**
* @brief Read data from a channel.
...
...
@@ -161,7 +160,7 @@ __API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_
* @retval -1 read failed(error).
* @retval none -1 the number of bytes read.
*/
__API__
int
tos_at_channel_read_timed
(
int
channel_id
,
uint8_t
*
buffer
,
size_t
buffer_len
,
uint32_t
timeout
);
__API__
int
tos_at_channel_read_timed
(
at_agent_t
*
at_agent
,
int
channel_id
,
uint8_t
*
buffer
,
size_t
buffer_len
,
uint32_t
timeout
);
/**
* @brief Read data from a channel.
...
...
@@ -177,7 +176,7 @@ __API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t bu
* @retval -1 read failed(error).
* @retval none -1 the number of bytes read.
*/
__API__
int
tos_at_channel_read
(
int
channel_id
,
uint8_t
*
buffer
,
size_t
buffer_len
);
__API__
int
tos_at_channel_read
(
at_agent_t
*
at_agent
,
int
channel_id
,
uint8_t
*
buffer
,
size_t
buffer_len
);
/**
* @brief Allocate a channel.
...
...
@@ -193,7 +192,7 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l
* @retval -1 allocate failed(error).
* @retval none -1 the id of the channel.
*/
__API__
int
tos_at_channel_alloc_id
(
int
channel_id
,
const
char
*
ip
,
const
char
*
port
);
__API__
int
tos_at_channel_alloc_id
(
at_agent_t
*
at_agent
,
int
channel_id
,
const
char
*
ip
,
const
char
*
port
);
/**
* @brief Allocate a channel.
...
...
@@ -208,7 +207,7 @@ __API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char *
* @retval -1 allocate failed(error).
* @retval none -1 the id of the channel.
*/
__API__
int
tos_at_channel_alloc
(
const
char
*
ip
,
const
char
*
port
);
__API__
int
tos_at_channel_alloc
(
at_agent_t
*
at_agent
,
const
char
*
ip
,
const
char
*
port
);
/**
* @brief Free a channel.
...
...
@@ -222,7 +221,7 @@ __API__ int tos_at_channel_alloc(const char *ip, const char *port);
* @retval -1 free failed(error).
* @retval 0 free successfully.
*/
__API__
int
tos_at_channel_free
(
int
channel_id
);
__API__
int
tos_at_channel_free
(
at_agent_t
*
at_agent
,
int
channel_id
);
/**
* @brief Set channel broken.
...
...
@@ -235,7 +234,7 @@ __API__ int tos_at_channel_free(int channel_id);
* @retval -1 set failed(error).
* @retval 0 set successfully.
*/
__API__
int
tos_at_channel_set_broken
(
int
channel_id
);
__API__
int
tos_at_channel_set_broken
(
at_agent_t
*
at_agent
,
int
channel_id
);
/**
* @brief Judge whether channel is working.
...
...
@@ -246,7 +245,7 @@ __API__ int tos_at_channel_set_broken(int channel_id);
*
* @return at channel status(type of at_channel_status_t)
*/
__API__
int
tos_at_channel_is_working
(
int
channel_id
);
__API__
int
tos_at_channel_is_working
(
at_agent_t
*
at_agent
,
int
channel_id
);
/**
* @brief Initialize the at framework.
...
...
@@ -261,7 +260,7 @@ __API__ int tos_at_channel_is_working(int channel_id);
* @retval -1 initialize failed(error).
* @retval 0 initialize successfully.
*/
__API__
int
tos_at_init
(
hal_uart_port_t
uart_port
,
at_event_t
*
event_table
,
size_t
event_table_size
);
__API__
int
tos_at_init
(
at_agent_t
*
at_agent
,
k_stack_t
*
stk
,
hal_uart_port_t
uart_port
,
at_event_t
*
event_table
,
size_t
event_table_size
);
/**
* @brief De-initialize the at framework.
...
...
@@ -271,7 +270,7 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size
* @return
None
*/
__API__
void
tos_at_deinit
(
void
);
__API__
void
tos_at_deinit
(
at_agent_t
*
at_agent
);
/**
* @brief Create a echo struct.
...
...
@@ -318,7 +317,7 @@ __API__ int tos_at_echo_fuzzy_matching_create(at_echo_t *echo, char *buffer, siz
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__
int
tos_at_cmd_exec
(
at_echo_t
*
echo
,
uint32_t
timeout
,
const
char
*
cmd
,
...);
__API__
int
tos_at_cmd_exec
(
at_
agent_t
*
at_agent
,
at_
echo_t
*
echo
,
uint32_t
timeout
,
const
char
*
cmd
,
...);
/**
* @brief Execute an at command.
...
...
@@ -334,7 +333,7 @@ __API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd,
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__
int
tos_at_cmd_exec_until
(
at_echo_t
*
echo
,
uint32_t
timeout
,
const
char
*
cmd
,
...);
__API__
int
tos_at_cmd_exec_until
(
at_
agent_t
*
at_agent
,
at_
echo_t
*
echo
,
uint32_t
timeout
,
const
char
*
cmd
,
...);
/**
* @brief Send raw data througth uart.
...
...
@@ -350,7 +349,7 @@ __API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__
int
tos_at_raw_data_send
(
at_echo_t
*
echo
,
uint32_t
timeout
,
const
uint8_t
*
buf
,
size_t
size
);
__API__
int
tos_at_raw_data_send
(
at_
agent_t
*
at_agent
,
at_
echo_t
*
echo
,
uint32_t
timeout
,
const
uint8_t
*
buf
,
size_t
size
);
/**
* @brief Send raw data througth uart.
...
...
@@ -367,7 +366,7 @@ __API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__
int
tos_at_raw_data_send_until
(
at_echo_t
*
echo
,
uint32_t
timeout
,
const
uint8_t
*
buf
,
size_t
size
);
__API__
int
tos_at_raw_data_send_until
(
at_
agent_t
*
at_agent
,
at_
echo_t
*
echo
,
uint32_t
timeout
,
const
uint8_t
*
buf
,
size_t
size
);
/**
* @brief Write byte to the at uart.
...
...
@@ -379,7 +378,7 @@ __API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const
*
* @return None
*/
__API__
void
tos_at_uart_input_byte
(
uint8_t
data
);
__API__
void
tos_at_uart_input_byte
(
at_agent_t
*
at_agent
,
uint8_t
data
);
/**
* @brief A global lock provided by at framework.
...
...
@@ -393,7 +392,7 @@ __API__ void tos_at_uart_input_byte(uint8_t data);
* @retval -1 pend failed(error).
* @retval 0 pend successfully.
*/
__API__
int
tos_at_global_lock_pend
(
void
);
__API__
int
tos_at_global_lock_pend
(
at_agent_t
*
at_agent
);
/**
* @brief A global lock provided by at framework.
...
...
@@ -407,7 +406,7 @@ __API__ int tos_at_global_lock_pend(void);
* @retval -1 post failed(error).
* @retval 0 post successfully.
*/
__API__
int
tos_at_global_lock_post
(
void
);
__API__
int
tos_at_global_lock_post
(
at_agent_t
*
at_agent
);
/**
* @brief Read data from the uart.
...
...
@@ -420,7 +419,7 @@ __API__ int tos_at_global_lock_post(void);
*
* @return length of the data read from the uart.
*/
__API__
int
tos_at_uart_read
(
uint8_t
*
buffer
,
size_t
buffer_len
);
__API__
int
tos_at_uart_read
(
at_agent_t
*
at_agent
,
uint8_t
*
buffer
,
size_t
buffer_len
);
/**
* @brief Read data from the uart.
...
...
@@ -433,7 +432,7 @@ __API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len);
*
* @return length of the data read from the uart.
*/
__API__
int
tos_at_uart_readline
(
uint8_t
*
buffer
,
size_t
buffer_len
);
__API__
int
tos_at_uart_readline
(
at_agent_t
*
at_agent
,
uint8_t
*
buffer
,
size_t
buffer_len
);
/**
* @brief Read data from the uart.
...
...
@@ -446,7 +445,7 @@ __API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len);
*
* @return length of the data read from the uart.
*/
__API__
int
tos_at_uart_drain
(
uint8_t
*
buffer
,
size_t
buffer_len
);
__API__
int
tos_at_uart_drain
(
at_agent_t
*
at_agent
,
uint8_t
*
buffer
,
size_t
buffer_len
);
/**
* @brief Get the remote ip of a channel.
...
...
net/at/src/tos_at.c
浏览文件 @
122fa9fd
此差异已折叠。
点击以展开。
net/sal_module_wrapper/sal_module_wrapper.c
浏览文件 @
122fa9fd
#include "sal_module_wrapper.h"
static
sal_module_t
*
g_sal_module
=
NULL
;
static
sal_module_t
*
cur_sal_module
=
NULL
;
static
k_list_t
sal_module_device_list
;
int
tos_sal_module_register
(
sal_module_t
*
module
)
{
if
(
!
g_sal_module
)
{
g_sal_module
=
module
;
if
(
!
module
)
{
return
-
1
;
}
if
(
sal_module_device_list
.
next
==
NULL
||
sal_module_device_list
.
prev
==
NULL
)
{
\
tos_list_init
(
&
sal_module_device_list
);
}
tos_list_add_tail
(
&
module
->
sal_module_list
,
&
sal_module_device_list
);
return
0
;
}
int
tos_sal_module_unregister
(
sal_module_t
*
module
)
{
if
(
!
module
)
{
return
-
1
;
}
tos_list_del
(
&
module
->
sal_module_list
);
return
0
;
}
int
tos_sal_module_set_status
(
sal_module_t
*
module
,
sal_device_status_t
status
)
{
if
(
module
)
{
module
->
sal_module_status
=
status
;
return
0
;
}
return
-
1
;
}
int
tos_sal_module_register_default
(
)
void
tos_sal_module_set_local_ip
(
sal_module_t
*
module
,
char
*
ip
)
{
g_sal_module
=
NULL
;
if
(
module
&&
ip
)
{
strncpy
(
module
->
sal_module_ip
,
ip
,
sizeof
(
module
->
sal_module_ip
));
}
return
0
;
return
;
}
int
tos_sal_module_set_default
(
char
*
sal_module_device_name
)
{
k_list_t
*
cur
=
NULL
;
sal_module_t
*
sal_module
=
NULL
;
TOS_LIST_FOR_EACH
(
cur
,
&
sal_module_device_list
)
{
sal_module
=
TOS_LIST_ENTRY
(
cur
,
sal_module_t
,
sal_module_list
);
if
(
sal_module
==
NULL
)
{
continue
;
}
else
{
if
(
strcmp
(
sal_module
->
sal_module_name
,
sal_module_device_name
)
==
0
)
{
// tos_list_del(cur);
// tos_list_add(cur, &sal_module_device_list);
cur_sal_module
=
sal_module
;
return
0
;
}
}
}
return
-
1
;
}
int
tos_sal_module_
init
(
void
)
int
tos_sal_module_
get_type
(
void
)
{
if
(
g_sal_module
&&
g_sal_module
->
init
)
{
return
g_sal_module
->
init
()
;
if
(
cur_sal_module
)
{
return
cur_sal_module
->
sal_module_type
;
}
return
-
1
;
}
// int tos_sal_module_init(void)
// {
// if (cur_sal_module && cur_sal_module->init) {
// return cur_sal_module->init();
// }
// return -1;
// }
int
tos_sal_module_parse_domain
(
const
char
*
host_name
,
char
*
host_ip
,
size_t
host_ip_len
)
{
if
(
g_sal_module
&&
g
_sal_module
->
parse_domain
)
{
return
g
_sal_module
->
parse_domain
(
host_name
,
host_ip
,
host_ip_len
);
if
(
cur_sal_module
&&
cur
_sal_module
->
parse_domain
)
{
return
cur
_sal_module
->
parse_domain
(
host_name
,
host_ip
,
host_ip_len
);
}
return
-
1
;
}
int
tos_sal_module_connect
(
const
char
*
ip
,
const
char
*
port
,
sal_proto_t
proto
)
{
if
(
g_sal_module
&&
g
_sal_module
->
connect
)
{
return
g
_sal_module
->
connect
(
ip
,
port
,
proto
);
if
(
cur_sal_module
&&
cur
_sal_module
->
connect
)
{
return
cur
_sal_module
->
connect
(
ip
,
port
,
proto
);
}
return
-
1
;
}
int
tos_sal_module_send
(
int
sock
,
const
void
*
buf
,
size_t
len
)
{
if
(
g_sal_module
&&
g
_sal_module
->
send
)
{
return
g
_sal_module
->
send
(
sock
,
buf
,
len
);
if
(
cur_sal_module
&&
cur
_sal_module
->
send
)
{
return
cur
_sal_module
->
send
(
sock
,
buf
,
len
);
}
return
-
1
;
}
int
tos_sal_module_recv
(
int
sock
,
void
*
buf
,
size_t
len
)
{
if
(
g_sal_module
&&
g
_sal_module
->
recv
)
{
return
g
_sal_module
->
recv
(
sock
,
buf
,
len
);
if
(
cur_sal_module
&&
cur
_sal_module
->
recv
)
{
return
cur
_sal_module
->
recv
(
sock
,
buf
,
len
);
}
return
-
1
;
}
int
tos_sal_module_recv_timeout
(
int
sock
,
void
*
buf
,
size_t
len
,
uint32_t
timeout
)
{
if
(
g_sal_module
&&
g
_sal_module
->
recv_timeout
)
{
return
g
_sal_module
->
recv_timeout
(
sock
,
buf
,
len
,
timeout
);
if
(
cur_sal_module
&&
cur
_sal_module
->
recv_timeout
)
{
return
cur
_sal_module
->
recv_timeout
(
sock
,
buf
,
len
,
timeout
);
}
return
-
1
;
}
int
tos_sal_module_sendto
(
int
sock
,
char
*
ip
,
char
*
port
,
const
void
*
buf
,
size_t
len
)
{
if
(
g_sal_module
&&
g
_sal_module
->
sendto
)
{
return
g
_sal_module
->
sendto
(
sock
,
ip
,
port
,
buf
,
len
);
if
(
cur_sal_module
&&
cur
_sal_module
->
sendto
)
{
return
cur
_sal_module
->
sendto
(
sock
,
ip
,
port
,
buf
,
len
);
}
return
-
1
;
}
int
tos_sal_module_recvfrom
(
int
sock
,
void
*
buf
,
size_t
len
)
{
if
(
g_sal_module
&&
g
_sal_module
->
recvfrom
)
{
return
g
_sal_module
->
recvfrom
(
sock
,
buf
,
len
);
if
(
cur_sal_module
&&
cur
_sal_module
->
recvfrom
)
{
return
cur
_sal_module
->
recvfrom
(
sock
,
buf
,
len
);
}
return
-
1
;
}
int
tos_sal_module_recvfrom_timeout
(
int
sock
,
void
*
buf
,
size_t
len
,
uint32_t
timeout
)
{
if
(
g_sal_module
&&
g
_sal_module
->
recvfrom_timeout
)
{
return
g
_sal_module
->
recvfrom_timeout
(
sock
,
buf
,
len
,
timeout
);
if
(
cur_sal_module
&&
cur
_sal_module
->
recvfrom_timeout
)
{
return
cur
_sal_module
->
recvfrom_timeout
(
sock
,
buf
,
len
,
timeout
);
}
return
-
1
;
}
int
tos_sal_module_close
(
int
sock
)
{
if
(
g_sal_module
&&
g
_sal_module
->
close
)
{
return
g
_sal_module
->
close
(
sock
);
if
(
cur_sal_module
&&
cur
_sal_module
->
close
)
{
return
cur
_sal_module
->
close
(
sock
);
}
return
-
1
;
}
...
...
net/sal_module_wrapper/sal_module_wrapper.h
浏览文件 @
122fa9fd
...
...
@@ -20,13 +20,39 @@
#include <stdint.h>
#include <stdio.h>
#include "tos_k.h"
#define SAL_MODULE_DEVICE_NAME_MAX 10
typedef
enum
sal_protocol_en
{
TOS_SAL_PROTO_TCP
,
TOS_SAL_PROTO_UDP
,
}
sal_proto_t
;
typedef
enum
sal_device_status_en
{
TOS_SAL_MODULE_AVAILABLE
,
TOS_SAL_MODULE_UNAVAILABLE
,
}
sal_device_status_t
;
typedef
enum
sal_device_type_en
{
TOS_SAL_MODULE_GPRS
,
TOS_SAL_MODULE_WIFI
,
TOS_SAL_MODULE_4G_LTE
,
TOS_SAL_MODULE_4G_CAT1
,
TOS_SAL_MODULE_NB_IOT
,
}
sal_device_type_t
;
typedef
struct
sal_module_st
{
char
sal_module_name
[
SAL_MODULE_DEVICE_NAME_MAX
];
char
sal_module_ip
[
15
];
k_list_t
sal_module_list
;
sal_device_type_t
sal_module_type
;
sal_device_status_t
sal_module_status
;
int
(
*
init
)(
void
);
int
(
*
get_local_mac
)(
char
*
mac
);
...
...
@@ -63,6 +89,8 @@ typedef struct sal_module_st {
*/
int
tos_sal_module_register
(
sal_module_t
*
module
);
int
tos_sal_module_unregister
(
sal_module_t
*
module
);
/**
* @brief Register a default sal module.
*
...
...
@@ -72,16 +100,24 @@ int tos_sal_module_register(sal_module_t *module);
*
* @return errcode
*/
int
tos_sal_module_register_default
(
void
);
/**
* @brief Initialize the module.
*
* @attention None
*
* @return errcode
*/
int
tos_sal_module_init
(
void
);
int
tos_sal_module_set_status
(
sal_module_t
*
module
,
sal_device_status_t
status
);
void
tos_sal_module_set_local_ip
(
sal_module_t
*
module
,
char
*
ip
);
int
tos_sal_module_set_default
(
char
*
sal_module_device_name
);
int
tos_sal_module_get_type
(
void
);
// /**
// * @brief Initialize the module.
// *
// * @attention None
// *
// * @return errcode
// */
// int tos_sal_module_init(void);
/**
* @brief Convert domain to ip address.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录