2015-02-12 18:06:34 +01:00
|
|
|
/*
|
2014-02-25 10:07:41 +01:00
|
|
|
* Copyright (C) 2014 INRIA.
|
2013-06-22 05:11:53 +02:00
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* 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.
|
2015-02-12 18:06:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup sys_shell_commands
|
2013-06-22 05:11:53 +02:00
|
|
|
* @{
|
2015-02-12 18:06:34 +01:00
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Provides shell commands to configure node id
|
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
2013-06-22 05:11:53 +02:00
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2015-03-20 08:51:45 +01:00
|
|
|
int _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]);
|
2014-05-12 02:44:57 +02:00
|
|
|
printf("Setting new id %ld\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");
|
2015-03-20 08:51:45 +01:00
|
|
|
return 1;
|
2010-12-01 16:26:48 +01:00
|
|
|
}
|
|
|
|
}
|
2015-03-20 08:51:45 +01:00
|
|
|
|
|
|
|
return 0;
|
2010-12-01 16:26:48 +01:00
|
|
|
}
|