mesh: Add start up management command chain
Subsystems (2)
PATCH 1/1 mesh: Add start up management command chain
This allows co-existense of meshd and bluetoothd. meshd will automatically take control of the first available LE-capable controller that is not in use , i.e., is poered down.
--- Makefile.mesh | 4 +- mesh/btmesh.c | 5 +- mesh/main.c | 22 ++--- mesh/mesh.c | 253 +++++++++++++++++++++++++++++++++++++++++++++----- mesh/mesh.h | 4 +- mesh/net.c | 49 +++++----- 6 files changed, 269 insertions(+), 68 deletions(-)
Makefile.mesh +2 -2
@@ -23,7 +23,7 @@ libexec_PROGRAMS += mesh/meshd mesh_meshd_SOURCES = $(mesh_sources) mesh/main.c mesh_meshd_LDADD = src/shared/ecc.lo src/shared/queue.lo src/shared/io-ell.lo \ - src/shared/util.lo src/shared/hci.lo \ + src/shared/util.lo src/shared/hci.lo src/shared/mgmt.lo \ @DBUS_LIBS@ @ELL_LIBS@ -ljson-c noinst_PROGRAMS += mesh/btmesh
@@ -34,7 +34,7 @@ mesh_btmesh_SOURCES = $(mesh_sources) \ mesh/btmesh.c mesh_btmesh_LDADD = src/shared/ecc.lo src/shared/queue.lo src/shared/io-ell.lo \ - src/shared/util.lo src/shared/hci.lo \ + src/shared/util.lo src/shared/hci.lo src/shared/mgmt.lo \ src/libshared-mainloop.la \ -lreadline @ELL_LIBS@ -ljson-c
mesh/btmesh.c +3 -2
@@ -153,8 +153,8 @@ int main(int argc, char *argv[])l_info ("Starting mesh on hci%d\n" , index); - mesh =mesh_create (index); -if (!mesh || !mesh_load_config (mesh, config_option)) { + mesh =mesh_new (index, config_option); +if (!mesh) {l_info ("Failed to create mesh\n" );bt_shell_cleanup ();return EXIT_FAILURE ;
@@ -170,6 +170,7 @@ int main(int argc, char *argv[])bt_shell_run ();mesh_unref (mesh); +mesh_cleanup ();l_main_exit ();return status;
mesh/main.c +8 -14
@@ -30,6 +30,9 @@#include <sys/stat.h> #include <ell/ell.h> +#include "lib/bluetooth.h" +#include "lib/mgmt.h" +#include "mesh/mesh.h" #include "mesh/net.h" #include "mesh/storage.h"
@@ -81,6 +84,7 @@ int main(int argc, char *argv[])sigset_t mask;struct bt_mesh *mesh =NULL ;const char *config_file =NULL ; +int index =MGMT_INDEX_NONE ;if (!l_main_init ())return -1 ;
@@ -107,12 +111,7 @@ int main(int argc, char *argv[]) goto done; } - mesh =mesh_create (atoi (str)); -if (!mesh) { -l_error ("Failed to initialize mesh" ); - status =EXIT_FAILURE ; - goto done; - } + index =atoi (str);break ;case 'n' :
@@ -135,14 +134,8 @@ int main(int argc, char *argv[]) } } -if (!mesh) { -usage (); - status =EXIT_FAILURE ; - goto done; - } - -if (!mesh_load_config (mesh, config_file)) { -l_error ("Failed to load mesh configuration: %s" , config_file); +if (!mesh_new (index, config_file)) { +l_error ("Failed to initialize mesh" ); status =EXIT_FAILURE ; goto done; }
@@ -168,6 +161,7 @@ int main(int argc, char *argv[]) done:mesh_unref (mesh); +mesh_cleanup ();l_main_exit ();return status;
mesh/mesh.c +230 -23
312 lines not on this page · raw message
mesh/mesh.h +2 -2
@@ -21,11 +21,11 @@struct bt_mesh ;struct mesh_net ; -struct bt_mesh *mesh_create (uint16_t index); +struct bt_mesh *mesh_new (uint16_t index,const char *in_config_name);struct bt_mesh *mesh_ref (struct bt_mesh *mesh);void mesh_unref (struct bt_mesh *mesh); -bool mesh_load_config (struct bt_mesh *mesh,const char *in_config_name);bool mesh_set_output (struct bt_mesh *mesh,const char *out_config_name); +void mesh_cleanup (void );const char *mesh_status_str (uint8_t err);/* Command line testing */
mesh/net.c +24 -25
77 lines not on this page · raw message
Signature · 1 line
2.17.1