51#include "trustzone/tz-radio.h"
55#define LOG_MODULE "TZRadio"
56#define LOG_LEVEL LOG_LEVEL_INFO
58static volatile bool rx_poll_requested;
60PROCESS(tz_radio_process,
"TZ radio process");
65 rx_poll_requested =
true;
75 result = tz_radio_init();
78 if(!tz_radio_register_rx_callback(rx_poll_callback)) {
79 LOG_ERR(
"Failed to register RX callback\n");
88nr_prepare(
const void *payload,
unsigned short payload_len)
90 return tz_radio_prepare(payload, payload_len);
94nr_transmit(
unsigned short transmit_len)
96 return tz_radio_transmit(transmit_len);
100nr_send(
const void *payload,
unsigned short payload_len)
102 return tz_radio_send(payload, payload_len);
106nr_read(
void *buf,
unsigned short buf_len)
108 return tz_radio_read(buf, buf_len);
112nr_channel_clear(
void)
114 return tz_radio_channel_clear();
118nr_receiving_packet(
void)
120 return tz_radio_receiving_packet();
124nr_pending_packet(
void)
126 return tz_radio_pending_packet();
132 return tz_radio_on();
138 return tz_radio_off();
144 return tz_radio_get_value(param, value);
150 return tz_radio_set_value(param, value);
154nr_get_object(radio_param_t param,
void *dest,
size_t size)
156 return tz_radio_get_object(param, dest, size);
160nr_set_object(radio_param_t param,
const void *src,
size_t size)
162 return tz_radio_set_object(param, src, size);
186 LOG_INFO(
"TZ radio process started\n");
191 if(rx_poll_requested) {
192 rx_poll_requested =
false;
194 if(tz_radio_pending_packet()) {
199 tz_radio_get_rx_attributes(&rssi, &lqi);
205 packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (
int)rssi);
206 packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, lqi);
207 LOG_DBG(
"RX %d bytes, delivering to MAC\n", len);
208 NETSTACK_MAC.
input();
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
void packetbuf_clear(void)
Clear and reset the packetbuf.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS_END()
Define the end of a process.
void process_start(struct process *p, process_data_t data)
Start a process.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
void process_poll(struct process *p)
Request a process to be polled.
enum radio_result_e radio_result_t
Radio return values when setting or getting radio parameters.
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio.
Header file for the logging system.
Include file for the Contiki low-layer network stack (NETSTACK)
Header file for the Packet buffer (packetbuf) management.
Header file for the radio API.
void(* input)(void)
Callback for getting notified of incoming packet.
The structure of a Contiki-NG radio device driver.