mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-18 18:30:29 +00:00
Cleaned up and re-formatted source of linuxradiodrv
This commit is contained in:
parent
113d9761f7
commit
43a327df5a
@ -72,7 +72,6 @@ init(void)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
prepare(const void *payload, unsigned short payload_len)
|
prepare(const void *payload, unsigned short payload_len)
|
||||||
{
|
{
|
||||||
@ -84,7 +83,6 @@ prepare(const void *payload, unsigned short payload_len)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
transmit(unsigned short transmit_len)
|
transmit(unsigned short transmit_len)
|
||||||
{
|
{
|
||||||
@ -97,7 +95,6 @@ transmit(unsigned short transmit_len)
|
|||||||
buflen = 0;
|
buflen = 0;
|
||||||
return RADIO_TX_OK;
|
return RADIO_TX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
my_send(const void *payload, unsigned short payload_len)
|
my_send(const void *payload, unsigned short payload_len)
|
||||||
{
|
{
|
||||||
@ -111,38 +108,32 @@ my_send(const void *payload, unsigned short payload_len)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
my_read(void *buf, unsigned short buf_len)
|
my_read(void *buf, unsigned short buf_len)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
channel_clear(void)
|
channel_clear(void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
receiving_packet(void)
|
receiving_packet(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pending_packet(void)
|
pending_packet(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
set_fd(fd_set *rset, fd_set *wset)
|
set_fd(fd_set *rset, fd_set *wset)
|
||||||
{
|
{
|
||||||
FD_SET(sockfd, rset);
|
FD_SET(sockfd, rset);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_fd(fd_set *rset, fd_set *wset)
|
handle_fd(fd_set *rset, fd_set *wset)
|
||||||
{
|
{
|
||||||
@ -154,27 +145,27 @@ handle_fd(fd_set *rset, fd_set *wset)
|
|||||||
NETSTACK_RDC.input();
|
NETSTACK_RDC.input();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct select_callback linuxradio_sock_callback = { set_fd, handle_fd };
|
static const struct select_callback linuxradio_sock_callback = { set_fd, handle_fd };
|
||||||
|
|
||||||
static int
|
static int
|
||||||
on(void)
|
on(void)
|
||||||
{
|
{
|
||||||
|
struct ifreq ifr;
|
||||||
|
int err;
|
||||||
|
struct sockaddr_ll sll;
|
||||||
|
|
||||||
sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IEEE802154));
|
sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IEEE802154));
|
||||||
if(sockfd < 0) {
|
if(sockfd < 0) {
|
||||||
perror("linuxradio socket()");
|
perror("linuxradio socket()");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
struct ifreq ifr;
|
/* TODO: interface should not be hard-coded */
|
||||||
// TODO: interface should not be hard-coded
|
|
||||||
strncpy((char *)ifr.ifr_name, "wpan0", IFNAMSIZ);
|
strncpy((char *)ifr.ifr_name, "wpan0", IFNAMSIZ);
|
||||||
int err = ioctl(sockfd, SIOCGIFINDEX, &ifr);
|
err = ioctl(sockfd, SIOCGIFINDEX, &ifr);
|
||||||
if(err == -1) {
|
if(err == -1) {
|
||||||
perror("linuxradio ioctl()");
|
perror("linuxradio ioctl()");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_ll sll;
|
|
||||||
sll.sll_family = AF_PACKET;
|
sll.sll_family = AF_PACKET;
|
||||||
sll.sll_ifindex = ifr.ifr_ifindex;
|
sll.sll_ifindex = ifr.ifr_ifindex;
|
||||||
sll.sll_protocol = htons(ETH_P_IEEE802154);
|
sll.sll_protocol = htons(ETH_P_IEEE802154);
|
||||||
@ -188,7 +179,6 @@ on(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
off(void)
|
off(void)
|
||||||
{
|
{
|
||||||
@ -196,7 +186,6 @@ off(void)
|
|||||||
sockfd = -1;
|
sockfd = -1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct radio_driver linuxradio_driver =
|
const struct radio_driver linuxradio_driver =
|
||||||
{
|
{
|
||||||
init,
|
init,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user