2013-06-22 05:11:53 +02:00
|
|
|
/**
|
|
|
|
* Shell commands for configuring the node id
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 INRIA.
|
|
|
|
*
|
|
|
|
* This file subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* @ingroup shell_commands
|
|
|
|
* @{
|
|
|
|
* @file sc_id.c
|
|
|
|
* @brief provides shell commands to configure node id
|
|
|
|
* @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>
|
2010-12-01 16:26:48 +01:00
|
|
|
#include <config.h>
|
2010-12-03 22:22:58 +01:00
|
|
|
#include <stdlib.h>
|
2010-12-01 16:26:48 +01:00
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
void _id_handler(char *id)
|
|
|
|
{
|
2010-12-03 22:22:58 +01:00
|
|
|
long newid;
|
2010-12-01 16:26:48 +01:00
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
newid = atoi(id + 3);
|
|
|
|
|
|
|
|
if(strlen(id) < 3) {
|
2011-04-06 11:11:03 +02:00
|
|
|
#ifdef MODULE_CONFIG
|
2010-12-03 22:22:58 +01:00
|
|
|
printf("Current id: %u\n", sysconfig.id);
|
2011-04-06 11:11:03 +02:00
|
|
|
#endif
|
2010-12-03 22:22:58 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Setting new id %lu\n", newid);
|
2010-12-06 13:19:31 +01:00
|
|
|
#ifdef MODULE_CONFIG
|
2010-12-13 01:29:46 +01:00
|
|
|
sysconfig.id = newid;
|
2013-06-22 05:11:53 +02:00
|
|
|
|
|
|
|
if(!config_save()) {
|
2010-12-01 16:26:48 +01:00
|
|
|
puts("ERROR setting new id");
|
|
|
|
}
|
2013-06-22 05:11:53 +02:00
|
|
|
|
2010-12-06 13:19:31 +01:00
|
|
|
#endif
|
2010-12-01 16:26:48 +01:00
|
|
|
}
|
|
|
|
}
|