22754053e8
drivers/wireless: Adds XBee S2C (802.15.4 firmware) support. XBee driver emulates mac802154 interface * drivers/wireless/xbee: Adds xbee_netdev. Very similar to mac802154_netdev * configs/same70-xplained: Starts adding support for XBee radio * drivers/wireless/ieee802154/xbee: More structuring of XBee driver * drivers/wireless/ieee802154/xbee: More Xbee work. Starts adding support on Clicker2 * drivers/wireless/ieee802154/xbee: More XBee MAC code * configs/clicker2-stm32: More work to add XBee radio support * drivers/wireless/ieee802154/xbee: Most of driver is now structured. No build errors * configs/clicker2-stm32: Adjustments to XBee click module support * drivers/xbee: Changes md_ prefix to xd_ prefix for xbeenet_driver_s fields * drivers/xbee: XBee network device now passes MAC events via IOCTL * drivers/xbee: Support querying device for parameters, setting parameters, and structures association/startpan logic * configs/clicker2-stm32: Fixes Xbee lower half ATTN poll logic * drivers/xbee: Removes dependce on CONFIG_IEEE802154_NETDEV * drivers/xbee: Supports MAC RESET.request primitive * drivers/xbee: Exposes generic AT query to the rest of driver * drivers/xbee: Sets local values when writing setting change to Xbee device * drivers/xbee: Finish association logic * drivers/xbee: Adds xbee_get_mhrlen( ) allocating enough space for API frame header to frame * drivers/xbee: Finishes transmit/receive logic * drivers/xbee: Fixes xbee_netdev to match logic in mac802154_netdev.c * drivers/xbee: Rearranges logic to prevent a loop condition where recursion could potentially occur to the point of deadlocking the system Approved-by: Gregory Nutt <gnutt@nuttx.org>
180 lines
6.0 KiB
C
180 lines
6.0 KiB
C
/****************************************************************************
|
|
* drivers/wireless/xbee/drivers/xbee_ioctl.c
|
|
*
|
|
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
|
* Author: Anthony Merlino <anthony@vergeaero.com>
|
|
*
|
|
* 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 NuttX 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
*
|
|
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
|
|
* COPYRIGHT OWNER 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.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <stdint.h>
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
#include <debug.h>
|
|
#include <string.h>
|
|
|
|
#include <nuttx/fs/ioctl.h>
|
|
|
|
#include <xbee.h>
|
|
#include <xbee_mac.h>
|
|
|
|
/****************************************************************************
|
|
* Pre-processor Definitions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Types
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Function Prototypes
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Data
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Public Data
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: xbee_ioctl
|
|
*
|
|
* Description:
|
|
* Handle MAC and radio IOCTL commands directed to the MAC.
|
|
*
|
|
* Parameters:
|
|
* mac - Reference to the XBee driver state structure
|
|
* cmd - The IOCTL command
|
|
* arg - The argument for the IOCTL command
|
|
*
|
|
* Returned Value:
|
|
* OK on success; Negated errno on failure.
|
|
*
|
|
****************************************************************************/
|
|
|
|
int xbee_ioctl(XBEEHANDLE xbee, int cmd, unsigned long arg)
|
|
{
|
|
int ret = -EINVAL;
|
|
|
|
FAR union ieee802154_macarg_u *macarg =
|
|
(FAR union ieee802154_macarg_u *)((uintptr_t)arg);
|
|
|
|
DEBUGASSERT(xbee != NULL);
|
|
|
|
/* Check for IOCTLs aimed at the IEEE802.15.4 MAC layer */
|
|
|
|
if (_MAC802154IOCVALID(cmd))
|
|
{
|
|
/* Handle the MAC IOCTL command */
|
|
|
|
switch (cmd)
|
|
{
|
|
case MAC802154IOC_MLME_GET_REQUEST:
|
|
{
|
|
ret = xbee_req_get(xbee, macarg->getreq.attr,
|
|
&macarg->getreq.attrval);
|
|
}
|
|
break;
|
|
case MAC802154IOC_MLME_SET_REQUEST:
|
|
{
|
|
ret = xbee_req_set(xbee, macarg->setreq.attr,
|
|
&macarg->setreq.attrval);
|
|
}
|
|
break;
|
|
case MAC802154IOC_MLME_START_REQUEST:
|
|
{
|
|
ret = xbee_req_start(xbee, &macarg->startreq);
|
|
}
|
|
break;
|
|
case MAC802154IOC_MLME_ASSOC_REQUEST:
|
|
{
|
|
ret = xbee_req_associate(xbee, &macarg->assocreq);
|
|
}
|
|
break;
|
|
case MAC802154IOC_MLME_RESET_REQUEST:
|
|
{
|
|
ret = xbee_req_reset(xbee, macarg->resetreq.resetattr);
|
|
}
|
|
break;
|
|
#if 0
|
|
case MAC802154IOC_MLME_ASSOC_RESPONSE:
|
|
{
|
|
ret = xbee_resp_associate(xbee, &macarg->assocresp);
|
|
}
|
|
break;
|
|
case MAC802154IOC_MLME_DISASSOC_REQUEST:
|
|
{
|
|
ret = xbee_req_disassociate(xbee, &macarg->disassocreq);
|
|
}
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_RXENABLE_REQUEST:
|
|
{
|
|
ret = xbee_req_rxenable(xbee, &macarg->rxenabreq);
|
|
}
|
|
break;
|
|
case MAC802154IOC_MLME_SCAN_REQUEST:
|
|
{
|
|
ret = xbee_req_scan(xbee, &macarg->scanreq);
|
|
}
|
|
break;
|
|
|
|
|
|
case MAC802154IOC_MLME_POLL_REQUEST:
|
|
{
|
|
ret = xbee_req_poll(xbee, &macarg->pollreq);
|
|
}
|
|
break;
|
|
#endif
|
|
default:
|
|
wlerr("ERROR: Unrecognized cmd: %d\n", cmd);
|
|
ret = -ENOTTY;
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|