Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
7340e773
Commit
7340e773
authored
7 years ago
by
Vincent Dupont
Committed by
Kaspar Schleiser
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
drivers/at: add at_send_cmd_wait_prompt and at_send_bytes
parent
ee29b76c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/at/at.c
+29
-0
29 additions, 0 deletions
drivers/at/at.c
drivers/include/at.h
+24
-0
24 additions, 0 deletions
drivers/include/at.h
with
53 additions
and
0 deletions
drivers/at/at.c
+
29
−
0
View file @
7340e773
...
@@ -54,6 +54,11 @@ int at_expect_bytes(at_dev_t *dev, const char *bytes, size_t len, uint32_t timeo
...
@@ -54,6 +54,11 @@ int at_expect_bytes(at_dev_t *dev, const char *bytes, size_t len, uint32_t timeo
return
0
;
return
0
;
}
}
void
at_send_bytes
(
at_dev_t
*
dev
,
const
char
*
bytes
,
size_t
len
)
{
uart_write
(
dev
->
uart
,
(
const
uint8_t
*
)
bytes
,
len
);
}
int
at_send_cmd
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
int
at_send_cmd
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
{
{
unsigned
cmdlen
=
strlen
(
command
);
unsigned
cmdlen
=
strlen
(
command
);
...
@@ -155,6 +160,30 @@ out:
...
@@ -155,6 +160,30 @@ out:
return
res
;
return
res
;
}
}
int
at_send_cmd_wait_prompt
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
{
unsigned
cmdlen
=
strlen
(
command
);
at_drain
(
dev
);
uart_write
(
dev
->
uart
,
(
const
uint8_t
*
)
command
,
cmdlen
);
uart_write
(
dev
->
uart
,
(
const
uint8_t
*
)
AT_END_OF_LINE
,
sizeof
(
AT_END_OF_LINE
)
-
1
);
if
(
at_expect_bytes
(
dev
,
command
,
cmdlen
,
timeout
))
{
return
-
1
;
}
if
(
at_expect_bytes
(
dev
,
AT_END_OF_LINE
"
\n
"
,
sizeof
(
AT_END_OF_LINE
),
timeout
))
{
return
-
2
;
}
if
(
at_expect_bytes
(
dev
,
">"
,
1
,
timeout
))
{
return
-
3
;
}
return
0
;
}
int
at_send_cmd_wait_ok
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
int
at_send_cmd_wait_ok
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
{
{
int
res
;
int
res
;
...
...
This diff is collapsed.
Click to expand it.
drivers/include/at.h
+
24
−
0
View file @
7340e773
...
@@ -84,6 +84,21 @@ int at_dev_init(at_dev_t *dev, uart_t uart, uint32_t baudrate, char *buf, size_t
...
@@ -84,6 +84,21 @@ int at_dev_init(at_dev_t *dev, uart_t uart, uint32_t baudrate, char *buf, size_t
*/
*/
int
at_send_cmd_wait_ok
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
);
int
at_send_cmd_wait_ok
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
);
/**
* @brief send AT command, wait for a prompt
*
* This function will send the supplied @p command, then wait for the prompt (>)
* character and return
*
* @param[in] dev device to operate on
* @param[in] command command string to send
* @param[in] timeout timeout (in usec)
*
* @return 0 when prompt is received
* @return <0 otherwise
*/
int
at_send_cmd_wait_prompt
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
);
/**
/**
* @brief send AT command, wait for response
* @brief send AT command, wait for response
*
*
...
@@ -136,6 +151,15 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command, char *resp_buf
...
@@ -136,6 +151,15 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command, char *resp_buf
*/
*/
int
at_expect_bytes
(
at_dev_t
*
dev
,
const
char
*
bytes
,
size_t
len
,
uint32_t
timeout
);
int
at_expect_bytes
(
at_dev_t
*
dev
,
const
char
*
bytes
,
size_t
len
,
uint32_t
timeout
);
/**
* @brief Send raw bytes to a device
*
* @param[in] dev device to operate on
* @param[in] bytes buffer containing bytes to send
* @param[in] len number of bytes to send
*/
void
at_send_bytes
(
at_dev_t
*
dev
,
const
char
*
bytes
,
size_t
len
);
/**
/**
* @brief send command to device
* @brief send command to device
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment