2013-06-22 05:11:53 +02:00
|
|
|
/**
|
2014-02-11 18:15:43 +01:00
|
|
|
* Shell commands for configuring the node id
|
2013-06-22 05:11:53 +02:00
|
|
|
*
|
2014-02-25 10:07:41 +01:00
|
|
|
* Copyright (C) 2014 INRIA.
|
2013-06-22 05:11:53 +02:00
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-06-22 05:11:53 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* @ingroup shell_commands
|
|
|
|
* @{
|
|
|
|
* @file sc_id.c
|
2014-02-11 18:15:43 +01:00
|
|
|
* @brief provides shell commands to configure node id
|
2013-06-22 05:11:53 +02:00
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2010-12-01 16:26:48 +01:00
|
|
|
#include <stdio.h>
|
2010-12-03 22:22:58 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2013-12-16 17:54:58 +01:00
|
|
|
#include "config.h"
|
2010-12-01 16:26:48 +01:00
|
|
|
|
2014-02-21 19:10:24 +01:00
|
|
|
void _id_handler(int argc, char **argv)
|
2013-06-22 05:11:53 +02:00
|
|
|
{
|
2014-02-21 19:10:24 +01:00
|
|
|
if (argc < 2) {
|
2010-12-03 22:22:58 +01:00
|
|
|
printf("Current id: %u\n", sysconfig.id);
|
|
|
|
}
|
|
|
|
else {
|
2014-02-21 19:10:24 +01:00
|
|
|
long newid = atoi(argv[1]);
|
2010-12-03 22:22:58 +01:00
|
|
|
printf("Setting new id %lu\n", newid);
|
2010-12-13 01:29:46 +01:00
|
|
|
sysconfig.id = newid;
|
2013-06-22 05:11:53 +02:00
|
|
|
|
2013-06-24 22:37:35 +02:00
|
|
|
if (!config_save()) {
|
2010-12-01 16:26:48 +01:00
|
|
|
puts("ERROR setting new id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|