Contiki 2.6
|
Example glue code between the existing MAC code and the Contiki mac interface. More...
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <avr/eeprom.h>
#include <util/delay.h>
#include "net/packetbuf.h"
#include "zmac.h"
#include "mac.h"
#include "frame.h"
#include "radio.h"
#include "tcpip.h"
#include "sicslowmac.h"
#include "sicslowpan.h"
#include "ieee-15-4-manager.h"
Go to the source code of this file.
Functions | |
uint8_t | mac_event_pending (void) |
Checks for any pending events in the queue. | |
void | mac_put_event (event_object_t *object) |
Puts an event into the queue of events. | |
event_object_t * | mac_get_event (void) |
Pulls an event from the event queue. | |
void | mac_task (process_event_t ev, process_data_t data) |
This is the main loop task for the MAC. | |
int | sicslowmac_dataRequest (void) |
This is the implementation of the 15.4 MAC Data Request primitive. | |
int | mac_wake (void) |
Stub function that will be implemented in phase 2 to cause end nodes to sleep. | |
int | mac_sleep (void) |
Stub function that will be implemented in phase 2 to cause end nodes to sleep. | |
void | sicslowmac_resetRequest (bool setDefaultPIB) |
This is the implementation of the 15.4 MAC Reset Request primitive. | |
PROCESS_THREAD (mac_process, ev, data) | |
Variables | |
ieee_15_4_manager_t | ieee15_4ManagerAddress |
Interface structure for this module. |
Example glue code between the existing MAC code and the Contiki mac interface.
Definition in file sicslowmac.c.
uint8_t mac_event_pending | ( | void | ) |
Checks for any pending events in the queue.
Definition at line 123 of file sicslowmac.c.
Referenced by mac_task().
event_object_t* mac_get_event | ( | void | ) |
Pulls an event from the event queue.
Assumes that there is an event in the queue. See mac_event_pending().
Definition at line 163 of file sicslowmac.c.
References NULL.
Referenced by mac_task().
void mac_put_event | ( | event_object_t * | object | ) |
Puts an event into the queue of events.
object | is a pointer to the event to add to queue. |
Definition at line 134 of file sicslowmac.c.
Referenced by rx_frame_parse().
void mac_task | ( | process_event_t | ev, |
process_data_t | data | ||
) |
This is the main loop task for the MAC.
Called by the main application loop.
Definition at line 194 of file sicslowmac.c.
References mac_event_pending(), and mac_get_event().
Referenced by PROCESS_THREAD().
PROCESS_THREAD | ( | mac_process | , |
ev | , | ||
data | |||
) |
Definition at line 593 of file sicslowmac.c.
References ieee_15_4_init(), mac_init(), mac_task(), NULL, PROCESS_BEGIN, PROCESS_END, PROCESS_POLLHANDLER, PROCESS_YIELD, radio_init(), radio_set_operating_channel(), radio_set_trx_state(), RADIO_SUCCESS, radio_use_auto_tx_crc(), RX_AACK_ON, mac_driver::send, sicslowmac_dataRequest(), and TRX_OFF.
int sicslowmac_dataRequest | ( | void | ) |
This is the implementation of the 15.4 MAC Data Request primitive.
0 | Failure. |
1 | Success. |
The data request primitive creates the frame header based on static and dynamic data. The static data will be refined in phase II of the project. The frame payload and length are retrieved from the rime buffer and rime length respectively.
When the header and payload are assembled into the frame_create_params structure, the frame is created by a call to frame_tx_create and then transmited via radio_send_data.
Definition at line 397 of file sicslowmac.c.
References fcf_t::ackRequired, addr_t::addr16, addr_t::addr64, frame_create_params_t::dest_addr, frame_create_params_t::dest_pid, fcf_t::destAddrMode, frame_create_params_t::fcf, frame_result_t::frame, frame_tx_create(), fcf_t::framePending, fcf_t::frameType, fcf_t::frameVersion, ieee_15_4_manager::get_dst_panid, ieee_15_4_manager::get_long_addr, ieee_15_4_manager::get_src_panid, frame_result_t::length, macDSN, packetbuf_datalen(), packetbuf_dataptr(), fcf_t::panIdCompression, frame_create_params_t::payload, frame_create_params_t::payload_len, radio_send_data(), RADIO_SUCCESS, RADIO_WRONG_STATE, rimeaddr_cmp(), rimeaddr_null, fcf_t::securityEnabled, frame_create_params_t::seq, frame_create_params_t::src_addr, frame_create_params_t::src_pid, and fcf_t::srcAddrMode.
Referenced by PROCESS_THREAD().
void sicslowmac_resetRequest | ( | bool | setDefaultPIB | ) |
This is the implementation of the 15.4 MAC Reset Request primitive.
setDefaultPIB | True if the default PIB values should be set. |
0 | Failure. |
1 | Success. |
Sets all PIB values to default.
Definition at line 560 of file sicslowmac.c.
References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, macCoordShortAddress, macDSN, macDstPANId, macLongAddr, macShortAddress, and macSrcPANId.
Referenced by mac_init().