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
899d7fee
Commit
899d7fee
authored
6 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
shell: add shell command for rdcli
parent
49f21b89
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sys/shell/commands/Makefile
+3
-0
3 additions, 0 deletions
sys/shell/commands/Makefile
sys/shell/commands/sc_rdcli.c
+130
-0
130 additions, 0 deletions
sys/shell/commands/sc_rdcli.c
sys/shell/commands/shell_commands.c
+7
-0
7 additions, 0 deletions
sys/shell/commands/shell_commands.c
with
140 additions
and
0 deletions
sys/shell/commands/Makefile
+
3
−
0
View file @
899d7fee
...
@@ -66,6 +66,9 @@ endif
...
@@ -66,6 +66,9 @@ endif
ifneq
(,$(filter conn_can,$(USEMODULE)))
ifneq
(,$(filter conn_can,$(USEMODULE)))
SRC
+=
sc_can.c
SRC
+=
sc_can.c
endif
endif
ifneq
(,$(filter rdcli,$(USEMODULE)))
SRC
+=
sc_rdcli.c
endif
ifneq
(,$(filter periph_rtc,$(FEATURES_PROVIDED)))
ifneq
(,$(filter periph_rtc,$(FEATURES_PROVIDED)))
SRC
+=
sc_rtc.c
SRC
+=
sc_rtc.c
...
...
This diff is collapsed.
Click to expand it.
sys/shell/commands/sc_rdcli.c
0 → 100644
+
130
−
0
View file @
899d7fee
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_shell_commands
* @{
*
* @file
* @brief Shell commands for the rdcli module
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include
<stdio.h>
#include
<stdlib.h>
#include
"net/rdcli.h"
#include
"net/nanocoap.h"
#include
"net/sock/util.h"
#include
"net/rdcli_config.h"
#include
"net/rdcli_common.h"
static
int
make_sock_ep
(
sock_udp_ep_t
*
ep
,
const
char
*
addr
)
{
ep
->
port
=
0
;
if
(
sock_udp_str2ep
(
ep
,
addr
)
<
0
)
{
return
-
1
;
}
ep
->
family
=
AF_INET6
;
ep
->
netif
=
SOCK_ADDR_ANY_NETIF
;
if
(
ep
->
port
==
0
)
{
ep
->
port
=
RDCLI_SERVER_PORT
;
}
return
0
;
}
int
_rdcli_handler
(
int
argc
,
char
**
argv
)
{
int
res
;
if
((
argc
>
1
)
&&
(
strcmp
(
argv
[
1
],
"register"
)
==
0
))
{
char
*
regif
=
NULL
;
if
(
argc
<
3
)
{
printf
(
"usage: %s register <server address> [registration interface]
\n
"
,
argv
[
0
]);
return
1
;
}
sock_udp_ep_t
remote
;
if
(
make_sock_ep
(
&
remote
,
argv
[
2
])
<
0
)
{
printf
(
"error: unable to parse address
\n
"
);
return
1
;
}
if
(
argc
>
3
)
{
regif
=
argv
[
3
];
}
puts
(
"Registering with RD now, this may take a short while..."
);
if
(
rdcli_register
(
&
remote
,
regif
)
!=
RDCLI_OK
)
{
puts
(
"error: registration failed"
);
}
else
{
puts
(
"registration successful
\n
"
);
rdcli_dump_status
();
}
}
else
if
((
argc
>
1
)
&&
(
strcmp
(
argv
[
1
],
"discover"
)
==
0
))
{
if
(
argc
<
3
)
{
printf
(
"usage: %s discover <server address>
\n
"
,
argv
[
0
]);
return
1
;
}
char
regif
[
NANOCOAP_URI_MAX
];
sock_udp_ep_t
remote
;
if
(
make_sock_ep
(
&
remote
,
argv
[
2
])
<
0
)
{
printf
(
"error: unable to parse address
\n
"
);
return
1
;
}
if
(
rdcli_discover_regif
(
&
remote
,
regif
,
sizeof
(
regif
))
==
RDCLI_OK
)
{
printf
(
"the registration interface is '%s'
\n
"
,
regif
);
}
else
{
printf
(
"error: unable to discover registration interface
\n
"
);
}
}
else
if
((
argc
>
1
)
&&
(
strcmp
(
argv
[
1
],
"update"
)
==
0
))
{
res
=
rdcli_update
();
if
(
res
==
RDCLI_OK
)
{
puts
(
"RD update successful"
);
}
else
if
(
res
==
RDCLI_NORD
)
{
puts
(
"error: not associated with any RD"
);
}
else
if
(
res
==
RDCLI_TIMEOUT
)
{
puts
(
"error: unable to reach RD - dropped association"
);
}
else
{
puts
(
"error: RD update failed"
);
}
}
else
if
((
argc
>
1
)
&&
(
strcmp
(
argv
[
1
],
"remove"
)
==
0
))
{
res
=
rdcli_remove
();
if
(
res
==
RDCLI_OK
)
{
puts
(
"node successfully removed from RD"
);
}
else
if
(
res
==
RDCLI_NORD
)
{
puts
(
"error: not associated with any RD"
);
}
else
if
(
res
==
RDCLI_TIMEOUT
)
{
puts
(
"error: unable to reach RD - remove association only locally"
);
}
else
{
puts
(
"error: unable to remove node from RD"
);
}
}
else
if
((
argc
>
1
)
&&
(
strcmp
(
argv
[
1
],
"info"
)
==
0
))
{
rdcli_dump_status
();
}
else
{
printf
(
"usage: %s <register|discover|update|remove|info>
\n
"
,
argv
[
0
]);
return
1
;
}
return
0
;
}
This diff is collapsed.
Click to expand it.
sys/shell/commands/shell_commands.c
+
7
−
0
View file @
899d7fee
...
@@ -142,6 +142,10 @@ extern int _ls_handler(int argc, char **argv);
...
@@ -142,6 +142,10 @@ extern int _ls_handler(int argc, char **argv);
extern
int
_can_handler
(
int
argc
,
char
**
argv
);
extern
int
_can_handler
(
int
argc
,
char
**
argv
);
#endif
#endif
#ifdef MODULE_RDCLI
extern
int
_rdcli_handler
(
int
argc
,
char
**
argv
);
#endif
const
shell_command_t
_shell_command_list
[]
=
{
const
shell_command_t
_shell_command_list
[]
=
{
{
"reboot"
,
"Reboot the node"
,
_reboot_handler
},
{
"reboot"
,
"Reboot the node"
,
_reboot_handler
},
#ifdef MODULE_CONFIG
#ifdef MODULE_CONFIG
...
@@ -232,6 +236,9 @@ const shell_command_t _shell_command_list[] = {
...
@@ -232,6 +236,9 @@ const shell_command_t _shell_command_list[] = {
#endif
#endif
#ifdef MODULE_CONN_CAN
#ifdef MODULE_CONN_CAN
{
"can"
,
"CAN commands"
,
_can_handler
},
{
"can"
,
"CAN commands"
,
_can_handler
},
#endif
#ifdef MODULE_RDCLI
{
"rdcli"
,
"CoAP RD client commands"
,
_rdcli_handler
},
#endif
#endif
{
NULL
,
NULL
,
NULL
}
{
NULL
,
NULL
,
NULL
}
};
};
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