Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
c2e6f20c
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c2e6f20c
编写于
8月 21, 2018
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[net][at] Modify the AT client initialization process, delete AT socket automatic initialization.
上级
622fa0e7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
43 deletion
+32
-43
components/net/at/at_socket/at_socket.c
components/net/at/at_socket/at_socket.c
+20
-27
components/net/at/include/at.h
components/net/at/include/at.h
+1
-1
components/net/at/src/at_client.c
components/net/at/src/at_client.c
+11
-15
未找到文件。
components/net/at/at_socket/at_socket.c
浏览文件 @
c2e6f20c
...
...
@@ -64,8 +64,6 @@ typedef enum {
/* the global array of available sockets */
static
struct
at_socket
sockets
[
AT_SOCKETS_NUM
]
=
{
0
};
/* the global AT socket lock */
static
rt_mutex_t
at_socket_lock
=
RT_NULL
;
/* AT device socket options */
static
struct
at_device_ops
*
at_dev_ops
=
RT_NULL
;
...
...
@@ -257,12 +255,23 @@ static void at_do_event_changes(struct at_socket *sock, at_event_t event, rt_boo
static
struct
at_socket
*
alloc_socket
(
void
)
{
char
sem_name
[
RT_NAME_MAX
]
;
char
lock_
name
[
RT_NAME_MAX
];
static
rt_mutex_t
at_slock
=
RT_NULL
;
char
name
[
RT_NAME_MAX
];
struct
at_socket
*
sock
;
int
idx
;
rt_mutex_take
(
at_socket_lock
,
RT_WAITING_FOREVER
);
if
(
at_slock
==
RT_NULL
)
{
/* create AT socket lock */
at_slock
=
rt_mutex_create
(
"at_s"
,
RT_IPC_FLAG_FIFO
);
if
(
at_slock
==
RT_NULL
)
{
LOG_E
(
"No memory for AT socket lock!"
);
return
RT_NULL
;
}
}
rt_mutex_take
(
at_slock
,
RT_WAITING_FOREVER
);
/* find an empty at socket entry */
for
(
idx
=
0
;
idx
<
AT_SOCKETS_NUM
&&
sockets
[
idx
].
magic
;
idx
++
);
...
...
@@ -282,25 +291,25 @@ static struct at_socket *alloc_socket(void)
sock
->
errevent
=
RT_NULL
;
rt_slist_init
(
&
sock
->
recvpkt_list
);
rt_snprintf
(
sem_name
,
RT_NAME_MAX
,
"%s%d"
,
"at_recv_notice_
"
,
idx
);
rt_snprintf
(
name
,
RT_NAME_MAX
,
"%s%d"
,
"at_sr
"
,
idx
);
/* create AT socket receive mailbox */
if
((
sock
->
recv_notice
=
rt_sem_create
(
sem_
name
,
0
,
RT_IPC_FLAG_FIFO
))
==
RT_NULL
)
if
((
sock
->
recv_notice
=
rt_sem_create
(
name
,
0
,
RT_IPC_FLAG_FIFO
))
==
RT_NULL
)
{
goto
__err
;
}
rt_snprintf
(
lock_name
,
RT_NAME_MAX
,
"%s%d"
,
"at_recv_lock_
"
,
idx
);
rt_snprintf
(
name
,
RT_NAME_MAX
,
"%s%d"
,
"at_sr
"
,
idx
);
/* create AT socket receive ring buffer lock */
if
((
sock
->
recv_lock
=
rt_mutex_create
(
lock_
name
,
RT_IPC_FLAG_FIFO
))
==
RT_NULL
)
if
((
sock
->
recv_lock
=
rt_mutex_create
(
name
,
RT_IPC_FLAG_FIFO
))
==
RT_NULL
)
{
goto
__err
;
}
rt_mutex_release
(
at_s
ocket_
lock
);
rt_mutex_release
(
at_slock
);
return
sock
;
__err:
rt_mutex_release
(
at_s
ocket_
lock
);
rt_mutex_release
(
at_slock
);
return
RT_NULL
;
}
...
...
@@ -486,7 +495,6 @@ static void at_closed_notice_cb(int socket, at_socket_evt_t event, const char *b
at_do_event_changes
(
sock
,
AT_EVENT_RECV
,
RT_TRUE
);
at_do_event_changes
(
sock
,
AT_EVENT_ERROR
,
RT_TRUE
);
// LOG_D("socket (%d) closed by remote");
sock
->
state
=
AT_SOCKET_CLOSED
;
rt_sem_release
(
sock
->
recv_notice
);
}
...
...
@@ -767,7 +775,6 @@ int at_send(int socket, const void *data, size_t size, int flags)
return
at_sendto
(
socket
,
data
,
size
,
flags
,
RT_NULL
,
0
);
}
int
at_getsockopt
(
int
socket
,
int
level
,
int
optname
,
void
*
optval
,
socklen_t
*
optlen
)
{
struct
at_socket
*
sock
;
...
...
@@ -1123,17 +1130,3 @@ void at_scoket_device_register(const struct at_device_ops *ops)
RT_ASSERT
(
ops
->
set_event_cb
);
at_dev_ops
=
(
struct
at_device_ops
*
)
ops
;
}
static
int
at_socket_init
(
void
)
{
/* create AT socket lock */
at_socket_lock
=
rt_mutex_create
(
"at_socket_lock"
,
RT_IPC_FLAG_FIFO
);
if
(
!
at_socket_lock
)
{
LOG_E
(
"No memory for AT socket lock!"
);
return
-
RT_ENOMEM
;
}
return
RT_EOK
;
}
INIT_COMPONENT_EXPORT
(
at_socket_init
);
components/net/at/include/at.h
浏览文件 @
c2e6f20c
...
...
@@ -27,7 +27,7 @@
#include <rtthread.h>
#define AT_SW_VERSION "0.
2.5
"
#define AT_SW_VERSION "0.
3.0
"
#define DBG_ENABLE
#define DBG_SECTION_NAME "AT"
...
...
components/net/at/src/at_client.c
浏览文件 @
c2e6f20c
...
...
@@ -663,6 +663,13 @@ void at_set_urc_table(const struct at_urc *table, rt_size_t size)
}
/**
* initialize AT client.
*
* @return 0: initialize success
* -1: initialize failed
* -5: no memory
*/
int
at_client_init
(
void
)
{
int
result
=
RT_EOK
;
...
...
@@ -747,11 +754,6 @@ int at_client_init(void)
goto
__exit
;
}
if
((
result
=
at_client_port_init
())
!=
RT_EOK
)
{
LOG_E
(
"AT client port initialize failed(%d)."
,
result
);
}
__exit:
if
(
!
result
)
{
...
...
@@ -773,14 +775,8 @@ __exit:
return
result
;
}
INIT_COMPONENT_EXPORT
(
at_client_init
);
RT_WEAK
int
at_client_port_init
(
void
)
{
at_client_local
->
urc_table
=
RT_NULL
;
at_client_local
->
urc_table_size
=
0
;
LOG_E
(
"The client porting initialize for AT client is not implement."
);
return
0
;
}
#ifdef FINSH_USING_MSH
#include <finsh.h>
MSH_CMD_EXPORT
(
at_client_init
,
initialize
AT
client
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录