text: /*************************************************************************************************/
  /*!
   *  \file
   *
   *  \brief  HCI Advertising Extensions (AE) command module.
   *
   *  Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
   *
   *  Copyright (c) 2019-2020 Packetcraft, Inc.
   *  
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *  
   *      http://www.apache.org/licenses/LICENSE-2.0
   *  
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  /*************************************************************************************************/
  
  #include <string.h>
  #include "wsf_types.h"
  #include "wsf_msg.h"
  #include "util/bstream.h"
  #include "hci_cmd.h"
  #include "hci_api.h"
  #include "hci_main.h"
  #include "wsf_assert.h"
  
  #include "ll_api.h"
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set advertising set random device address command.
   *
   *  \param      advHandle   Advertising handle.
   *  \param      pAddr       Random device address.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeSetAdvSetRandAddrCmd(uint8_t advHandle, const uint8_t *pAddr)
  {
    LlSetAdvSetRandAddr(advHandle, pAddr);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set extended advertising parameters command.
   *
   *  \param      advHandle    Advertising handle.
   *  \param      pExtAdvParam Extended advertising parameters.
   *
   *  \return None.
   */
  /*************************************************************************************************/
  void HciLeSetExtAdvParamCmd(uint8_t advHandle, hciExtAdvParam_t *pExtAdvParam)
  {
    LlSetExtAdvParam(advHandle, (LlExtAdvParam_t *)pExtAdvParam);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set extended advertising data command.
   *
   *  \param      advHandle   Advertising handle.
   *  \param      op          Operation.
   *  \param      fragPref    Fragment preference.
   *  \param      len         Data buffer length.
   *  \param      pData       Advertising data buffer.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeSetExtAdvDataCmd(uint8_t advHandle, uint8_t op, uint8_t fragPref, uint8_t len,
                             const uint8_t *pData)
  {
    LlSetExtAdvData(advHandle, op, fragPref, len, pData);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set extended scan response data command.
   *
   *  \param      advHandle   Advertising handle.
   *  \param      op          Operation.
   *  \param      fragPref    Fragment preference.
   *  \param      len         Data buffer length.
   *  \param      pData       Scan response data buffer.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeSetExtScanRespDataCmd(uint8_t advHandle, uint8_t op, uint8_t fragPref, uint8_t len,
                                  const uint8_t *pData)
  {
    LlSetExtScanRespData(advHandle, op, fragPref, len, pData);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set extended advertising enable command.
   *
   *  \param      enable      Set to TRUE to enable advertising, FALSE to disable advertising.
   *  \param      numSets     Number of advertising sets.
   *  \param      pScanParam  Advertising enable parameter array.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeSetExtAdvEnableCmd(uint8_t enable, uint8_t numSets, hciExtAdvEnableParam_t *pEnableParam)
  {
    WSF_ASSERT(numSets <= LL_MAX_ADV_SETS);
  
    LlExtAdvEnable(enable, numSets, (LlExtAdvEnableParam_t *)pEnableParam);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE read maximum advertising data length command.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeReadMaxAdvDataLen(void)
  {
    /* not used */
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE read number of supported advertising sets command.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeReadNumSupAdvSets(void)
  {
    /* not used */
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE remove advertising set command.
   *
   *  \param      advHandle    Advertising handle.
   *
   *  \return     Status error code.
   */
  /*************************************************************************************************/
  void HciLeRemoveAdvSet(uint8_t advHandle)
  {
    LlRemoveAdvSet(advHandle);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE clear advertising sets command.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeClearAdvSets(void)
  {
    LlClearAdvSets();
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set periodic advertising parameters command.
   *
   *  \param      advHandle       Advertising handle.
   *  \param      advIntervalMin  Periodic advertising interval minimum.
   *  \param      advIntervalMax  Periodic advertising interval maximum.
   *  \param      advProps        Periodic advertising properties.
   *
   *  \return None.
   */
  /*************************************************************************************************/
  void HciLeSetPerAdvParamCmd(uint8_t advHandle, uint16_t advIntervalMin, uint16_t advIntervalMax,
                              uint16_t advProps)
  {
    LlPerAdvParam_t perAdvParam;
    uint8_t status;
  
    perAdvParam.perAdvInterMin = advIntervalMin;
    perAdvParam.perAdvInterMax = advIntervalMax;
    perAdvParam.perAdvProp = advProps;
  
    status = LlSetPeriodicAdvParam(advHandle, &perAdvParam);
    (void)status;
  
    WSF_ASSERT(status == LL_SUCCESS);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set periodic advertising data command.
   *
   *  \param      advHandle   Advertising handle.
   *  \param      op          Operation.
   *  \param      len         Data buffer length.
   *  \param      pData       Advertising data buffer.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeSetPerAdvDataCmd(uint8_t advHandle, uint8_t op, uint8_t len, const uint8_t *pData)
  {
    uint8_t status;
  
    /* return value used when asserts are enabled */
    status = LlSetPeriodicAdvData(advHandle, op, len, pData);
    (void)status;
  
    WSF_ASSERT(status == LL_SUCCESS);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE set periodic advertising enable command.
   *
   *  \param      enable      Set to TRUE to enable advertising, FALSE to disable advertising.
   *  \param      advHandle   Advertising handle.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeSetPerAdvEnableCmd(uint8_t enable, uint8_t advHandle)
  {
    LlSetPeriodicAdvEnable(enable, advHandle);
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE read transmit power command.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeReadTxPower(void)
  {
    /* not used */
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE read RF path compensation command.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeReadRfPathComp(void)
  {
    /* not used */
  }
  
  /*************************************************************************************************/
  /*!
   *  \brief      HCI LE write RF path compensation command.
   *
   *  \param      txPathComp      RF transmit path compensation value.
   *  \param      rxPathComp      RF receive path compensation value.
   *
   *  \return     None.
   */
  /*************************************************************************************************/
  void HciLeWriteRfPathComp(int16_t txPathComp, int16_t rxPathComp)
  {
    LlWriteRfPathComp(txPathComp, rxPathComp);
  }
  