⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ieee-15-4-manager.c

📁 Contiki是一个开源
💻 C
字号:
/* * Copyright (c) 2008, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This file is part of the Contiki operating system. * * $Id: ieee-15-4-manager.c,v 1.2 2008/10/14 18:38:09 c_oflynn Exp $ *//** * * \addtogroup rf230mac * \{ *//** * \file * \brief  Interfaces the 802.15.4 MAC to upper network layers. * * \author *         Mike Vidales <mavida404@gmail.com> */#include "zmac.h"#include "radio.h"#include "ieee-15-4-manager.h"/*---------------------------------------------------------------------------*/static intwake(void){  /* Wake the radio. */  return radio_leave_sleep_mode();}/*---------------------------------------------------------------------------*/static intsleep(void){  /* Sleep the radio. */  return radio_enter_sleep_mode();}/*---------------------------------------------------------------------------*/static voidset_channel(int channel){  /* Set the channel. */  phyCurrentChannel = channel;  radio_set_operating_channel(phyCurrentChannel);}/*---------------------------------------------------------------------------*/static intget_channel(void){  /* Reads the current channel. */  phyCurrentChannel = radio_get_operating_channel();  return phyCurrentChannel;}/*---------------------------------------------------------------------------*/static voidset_dst_panid(int panid){  macDstPANId = panid;}/*---------------------------------------------------------------------------*/static intget_dst_panid(void){  return macDstPANId;}/*---------------------------------------------------------------------------*/static voidset_src_panid(int panid){  /* Writes the PAN_ID to the radio. */  macSrcPANId = panid;  radio_set_pan_id(macSrcPANId);}/*---------------------------------------------------------------------------*/static intget_src_panid(void){  /* Gets the PAN_ID from the radio. */  macSrcPANId = radio_get_pan_id();  return macSrcPANId;}/*---------------------------------------------------------------------------*/static voidset_auto_mode(bool mode){  autoModes = mode;}/*---------------------------------------------------------------------------*/static boolget_auto_mode(void){  return autoModes;}/*---------------------------------------------------------------------------*/static voidset_long_addr(uint64_t address){  /* Set the Long address in the radio. */  macLongAddr = address;  radio_set_extended_address((uint8_t *)&macLongAddr);}/*---------------------------------------------------------------------------*/static uint64_tget_long_addr(void){  /* Get the Long address from the radio. */  radio_get_extended_address((uint8_t *)&macLongAddr);  return macLongAddr;}/*---------------------------------------------------------------------------*/static voidset_short_addr(int address){  /* Set the Short address in the radio. */  macShortAddress = address;  radio_set_short_address(macShortAddress);}/*---------------------------------------------------------------------------*/static intget_short_addr(void){  /* Get the Short address from the radio. */  macShortAddress = radio_get_short_address();  return macShortAddress;}/*---------------------------------------------------------------------------*/static voidset_iamcoord_bit(bool iamcoord){    /** Set the iAmCoord bit. */    iAmCoord = iamcoord;    radio_set_device_role(iAmCoord);}/*---------------------------------------------------------------------------*/static boolget_iamcoord_bit(void){    /** Get the iAmCoord bit. */    iAmCoord = radio_get_device_role();    return iAmCoord;}/*---------------------------------------------------------------------------*/static voidset_coord_long_addr(uint64_t address){    macCoordExtendedAddress = address;}/*---------------------------------------------------------------------------*/static uint64_tget_coord_long_addr(void){    return macCoordExtendedAddress;}/*---------------------------------------------------------------------------*/static voidset_coord_short_addr(int address){    macCoordShortAddress = address;}/*---------------------------------------------------------------------------*/static intget_coord_short_addr(void){    return macCoordShortAddress;}/*---------------------------------------------------------------------------*/static voidset_dest_long_addr(uint64_t address){    macDestAddress = address;}/*---------------------------------------------------------------------------*/static uint64_tget_dest_long_addr(void){    return macDestAddress;}/*---------------------------------------------------------------------------*//** \brief initializes the 802.15.4 manager layer. *  \param pieee_15_4_manager Pointer to \ref ieee_15_4_manager */void ieee_15_4_init(ieee_15_4_manager_t *pieee_15_4_manager){/* Initialize the IEEE 15.4 manager. */  pieee_15_4_manager->wake = wake;  pieee_15_4_manager->sleep = sleep;  pieee_15_4_manager->set_channel = set_channel;  pieee_15_4_manager->get_channel = get_channel;  pieee_15_4_manager->set_dst_panid = set_dst_panid;  pieee_15_4_manager->get_dst_panid = get_dst_panid;  pieee_15_4_manager->set_src_panid = set_src_panid;  pieee_15_4_manager->get_src_panid = get_src_panid;  pieee_15_4_manager->set_auto_mode = set_auto_mode;  pieee_15_4_manager->get_auto_mode = get_auto_mode;  pieee_15_4_manager->set_long_addr = set_long_addr;  pieee_15_4_manager->get_long_addr = get_long_addr;  pieee_15_4_manager->set_short_addr = set_short_addr;  pieee_15_4_manager->get_short_addr = get_short_addr;  pieee_15_4_manager->set_iamcoord_bit = set_iamcoord_bit;  pieee_15_4_manager->get_iamcoord_bit = get_iamcoord_bit;  pieee_15_4_manager->set_coord_long_addr = set_coord_long_addr;  pieee_15_4_manager->get_coord_long_addr = get_coord_long_addr;  pieee_15_4_manager->set_coord_short_addr = set_coord_short_addr;  pieee_15_4_manager->get_coord_short_addr = get_coord_short_addr;  pieee_15_4_manager->set_dest_long_addr = set_dest_long_addr;  pieee_15_4_manager->get_dest_long_addr = get_dest_long_addr;}/** \} */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -