2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* nativenet transceiver interface
|
|
|
|
*
|
2014-02-11 18:15:43 +01:00
|
|
|
* A configurable transceiver for the native port.
|
2013-08-29 14:41:55 +02:00
|
|
|
*
|
|
|
|
* At the moment only the tap interface is supported, but more network
|
|
|
|
* layers are intended. So the "configurable" part is a lie for now ;-)
|
|
|
|
* The effect of calls like nativenet_set_channel depend on the
|
|
|
|
* network layer.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Ludwig Ortmann
|
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-08-29 14:41:55 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-11-27 17:54:30 +01:00
|
|
|
* @defgroup native_net
|
|
|
|
* @ingroup native_cpu
|
2013-08-29 14:41:55 +02:00
|
|
|
* @{
|
|
|
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
2013-08-15 19:39:29 +02:00
|
|
|
#ifndef NATIVENET_H
|
|
|
|
#define NATIVENET_H
|
|
|
|
|
2013-08-08 11:08:33 +02:00
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
|
|
|
#define RX_BUF_SIZE (10)
|
|
|
|
#define TRANSCEIVER_BUFFER_SIZE (3)
|
|
|
|
|
|
|
|
#ifndef NATIVE_MAX_DATA_LENGTH
|
2013-08-29 15:12:06 +02:00
|
|
|
#include "tap.h"
|
2013-12-13 18:53:48 +01:00
|
|
|
#ifdef MODULE_SIXLOWPAN
|
|
|
|
#define NATIVE_MAX_DATA_LENGTH (255)
|
|
|
|
#else
|
2013-08-29 15:12:06 +02:00
|
|
|
#define NATIVE_MAX_DATA_LENGTH (TAP_MAX_DATA)
|
2013-12-13 18:53:48 +01:00
|
|
|
#endif
|
2013-08-08 11:08:33 +02:00
|
|
|
#else
|
2013-08-29 15:12:06 +02:00
|
|
|
#warning be careful not to exceed (TAP_MAX_DATA) with NATIVE_MAX_DATA_LENGTH
|
2013-08-08 11:08:33 +02:00
|
|
|
#endif /* NATIVE_MAX_DATA_LENGTH */
|
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Initialize transceiver
|
|
|
|
*
|
|
|
|
* @param transceiver_pid the pid of the transceiver thread
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
void nativenet_init(int transceiver_pid);
|
2013-08-29 14:41:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shutdown transceiver
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
void nativenet_powerdown();
|
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Enable/disable monitor mode
|
|
|
|
*
|
|
|
|
* @param mode 0 off, 1 on
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
void nativenet_set_monitor(uint8_t mode);
|
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Send a packet
|
|
|
|
*
|
|
|
|
* @param packet a radio packet
|
2013-12-24 10:54:51 +01:00
|
|
|
* @return -1 if the operation failed, the number of transmitted bytes
|
|
|
|
* up to INT8_MAX otherwise
|
2013-08-29 14:41:55 +02:00
|
|
|
*/
|
2013-11-23 14:03:26 +01:00
|
|
|
int8_t nativenet_send(radio_packet_t *packet);
|
2013-08-08 11:08:33 +02:00
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Set transceiver address
|
|
|
|
*
|
|
|
|
* @param address the address
|
|
|
|
* @return the address
|
|
|
|
*/
|
2013-08-21 19:22:32 +02:00
|
|
|
radio_address_t nativenet_set_address(radio_address_t address);
|
2013-08-29 14:41:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get transceiver address
|
|
|
|
*
|
|
|
|
* @return the address
|
|
|
|
*/
|
2013-08-21 19:22:32 +02:00
|
|
|
radio_address_t nativenet_get_address();
|
2013-08-08 11:08:33 +02:00
|
|
|
|
2014-02-05 09:46:52 +01:00
|
|
|
/**
|
|
|
|
* @brief Sets the IEEE long address of the nativenet transceiver.
|
|
|
|
*
|
|
|
|
* @param[in] addr The desired address.
|
|
|
|
*
|
|
|
|
* @return The set address after calling.
|
|
|
|
*/
|
|
|
|
uint64_t nativenet_set_address_long(uint64_t addr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Gets the current IEEE long address of the nativenet
|
|
|
|
* transceiver.
|
|
|
|
*
|
|
|
|
* @return The current IEEE long address.
|
|
|
|
*/
|
|
|
|
uint64_t nativenet_get_address_long(void);
|
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Set transceiver channel
|
|
|
|
*
|
|
|
|
* @param channel the channel
|
|
|
|
* @return the channel
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
int16_t nativenet_set_channel(uint8_t channel);
|
2013-08-29 14:41:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get transceiver channel
|
|
|
|
*
|
|
|
|
* @return the channel
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
int16_t nativenet_get_channel();
|
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Set transceiver pan
|
|
|
|
*
|
|
|
|
* @param channel the pan
|
|
|
|
* @return the pan
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
uint16_t nativenet_set_pan(uint16_t pan);
|
2013-08-29 14:41:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get transceiver pan
|
|
|
|
*
|
|
|
|
* @return the pan
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
uint16_t nativenet_get_pan();
|
|
|
|
|
2013-08-29 14:41:55 +02:00
|
|
|
/**
|
|
|
|
* Enable transceiver rx mode
|
|
|
|
*/
|
2013-08-08 11:08:33 +02:00
|
|
|
void nativenet_switch_to_rx();
|
2013-08-29 14:41:55 +02:00
|
|
|
/** @} */
|
2013-08-15 19:39:29 +02:00
|
|
|
#endif /* NATIVENET_H */
|