mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Add getter and setter of long addresses to transceiver
This commit is contained in:
parent
fa11d82443
commit
7f8e2c2991
@ -107,6 +107,11 @@
|
||||
*/
|
||||
typedef uint16_t transceiver_type_t;
|
||||
|
||||
/**
|
||||
* @brief Data type to represent the transceiver's EUI-64.
|
||||
*/
|
||||
typedef uint64_t transceiver_eui64_t;
|
||||
|
||||
/**
|
||||
* @brief Message types for transceiver interface
|
||||
*/
|
||||
@ -129,6 +134,8 @@ enum transceiver_msg_type_t {
|
||||
SET_CHANNEL, ///< Set a new channel
|
||||
GET_ADDRESS, ///< Get the radio address
|
||||
SET_ADDRESS, ///< Set the radio address
|
||||
GET_LONG_ADDR, ///< Get the long radio address, if existing
|
||||
SET_LONG_ADDR, ///< Set the long radio address, if supported by hardware
|
||||
SET_MONITOR, ///< Set transceiver to monitor mode (disable address checking)
|
||||
GET_PAN, ///< Get current pan
|
||||
SET_PAN, ///< Set a new pan
|
||||
|
@ -80,6 +80,36 @@ void _transceiver_get_set_address_handler(int argc, char **argv)
|
||||
printf("[transceiver] got address: %" PRIu16 "\n", a);
|
||||
}
|
||||
|
||||
/* checked for type safety */
|
||||
void _transceiver_get_set_long_addr_handler(int argc, char **argv)
|
||||
{
|
||||
msg_t mesg;
|
||||
transceiver_command_t tcmd;
|
||||
transceiver_eui64_t a;
|
||||
|
||||
if (transceiver_pid < 0) {
|
||||
puts("Transceiver not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
tcmd.transceivers = _TC_TYPE;
|
||||
tcmd.data = &a;
|
||||
mesg.content.ptr = (char *) &tcmd;
|
||||
|
||||
if (argc > 1) {
|
||||
a = atoll(argv[1]);
|
||||
printf("[transceiver] trying to set EUI-64 %016"PRIx64"\n", a);
|
||||
mesg.type = SET_LONG_ADDR;
|
||||
}
|
||||
else {
|
||||
mesg.type = GET_LONG_ADDR;
|
||||
}
|
||||
|
||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
||||
printf("[transceiver] got EUI-64: %016"PRIx64"\n", a);
|
||||
}
|
||||
|
||||
|
||||
/* checked for type safety */
|
||||
void _transceiver_get_set_channel_handler(int argc, char **argv)
|
||||
{
|
||||
|
@ -65,7 +65,8 @@ extern void _reset_current_handler(int argc, char **argv);
|
||||
#define _TC_MON
|
||||
#define _TC_SEND
|
||||
#endif
|
||||
#if (defined(MODULE_CC2420) || defined(MODULE_NATIVENET))
|
||||
#if (defined(MODULE_CC2420) || defined(MODULE_AT86RF231) || defined(MODULE_NATIVENET))
|
||||
#define _TC_LONG_ADDR
|
||||
#define _TC_PAN
|
||||
#endif
|
||||
#else /* WITHOUT MODULE_TRANSCEIVER */
|
||||
@ -79,6 +80,9 @@ extern void _cc110x_get_set_channel_handler(int argc, char **argv);
|
||||
#ifdef _TC_ADDR
|
||||
extern void _transceiver_get_set_address_handler(int argc, char **argv);
|
||||
#endif
|
||||
#ifdef _TC_LONG_ADDR
|
||||
extern void _transceiver_get_set_long_addr_handler(int argc, char **argv);
|
||||
#endif
|
||||
#ifdef _TC_CHAN
|
||||
extern void _transceiver_get_set_channel_handler(int argc, char **argv);
|
||||
#endif
|
||||
@ -138,6 +142,9 @@ const shell_command_t _shell_command_list[] = {
|
||||
#ifdef _TC_ADDR
|
||||
{"addr", "Gets or sets the address for the transceiver", _transceiver_get_set_address_handler},
|
||||
#endif
|
||||
#ifdef _TC_LONG_ADDR
|
||||
{"eui64", "Gets or sets the EUI-64 for the transceiver", _transceiver_get_set_long_addr_handler},
|
||||
#endif
|
||||
#ifdef _TC_CHAN
|
||||
{"chan", "Gets or sets the channel for the transceiver", _transceiver_get_set_channel_handler},
|
||||
#endif
|
||||
|
@ -129,6 +129,9 @@ static int32_t get_channel(transceiver_type_t t);
|
||||
static int32_t set_channel(transceiver_type_t t, void *channel);
|
||||
static radio_address_t get_address(transceiver_type_t t);
|
||||
static radio_address_t set_address(transceiver_type_t t, void *address);
|
||||
static transceiver_eui64_t get_long_addr(transceiver_type_t t);
|
||||
static transceiver_eui64_t set_long_addr(transceiver_type_t t,
|
||||
void *address);
|
||||
static int32_t get_pan(transceiver_type_t t);
|
||||
static int32_t set_pan(transceiver_type_t t, void *pan);
|
||||
|
||||
@ -308,6 +311,16 @@ void run(void)
|
||||
msg_reply(&m, &m);
|
||||
break;
|
||||
|
||||
case GET_LONG_ADDR:
|
||||
*((transceiver_eui64_t *) cmd->data) = get_long_addr(cmd->transceivers);
|
||||
msg_reply(&m, &m);
|
||||
break;
|
||||
|
||||
case SET_LONG_ADDR:
|
||||
*((transceiver_eui64_t *) cmd->data) = set_long_addr(cmd->transceivers, cmd->data);
|
||||
msg_reply(&m, &m);
|
||||
break;
|
||||
|
||||
case SET_MONITOR:
|
||||
set_monitor(cmd->transceivers, cmd->data);
|
||||
break;
|
||||
@ -1026,6 +1039,62 @@ static radio_address_t set_address(transceiver_type_t t, void *address)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Get the current long address of transceiver device
|
||||
*
|
||||
* @param t The transceiver device
|
||||
*
|
||||
* @return The configured long address of the device, 0 on error
|
||||
*/
|
||||
static transceiver_eui64_t get_long_addr(transceiver_type_t t)
|
||||
{
|
||||
switch (t) {
|
||||
#ifdef MODULE_CC2420
|
||||
|
||||
case TRANSCEIVER_CC2420:
|
||||
return cc2420_get_address_long();
|
||||
#endif
|
||||
#ifdef MODULE_AT86RF231
|
||||
|
||||
case TRANSCEIVER_AT86RF231:
|
||||
return at86rf231_get_address_long();
|
||||
#endif
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Set the long address of the transceiver device
|
||||
*
|
||||
* @param t The transceiver device
|
||||
* @param address Generic pointer to the long address to set
|
||||
*
|
||||
* @return The new long radio address of the device, 0 on error
|
||||
*/
|
||||
static transceiver_eui64_t set_long_addr(transceiver_type_t t, void *address)
|
||||
{
|
||||
uint64_t addr = *((uint64_t *)address);
|
||||
|
||||
switch (t) {
|
||||
#ifdef MODULE_CC2420
|
||||
|
||||
case TRANSCEIVER_CC2420:
|
||||
return cc2420_set_address_long(addr);
|
||||
#endif
|
||||
#ifdef MODULE_AT86RF231
|
||||
|
||||
case TRANSCEIVER_AT86RF231:
|
||||
return at86rf231_set_address_long(addr);
|
||||
#endif
|
||||
|
||||
default:
|
||||
(void) addr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Set the transceiver device into monitor mode (disabling address check)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user