Fixed BLE advertisement on SimpleLink
A couple of issues was found: * Wrong CPE patches in RF settings * Wrong whitening init value for the CMD_BLE5_ADV_NC command * BLE MAC address was not copied to RAM before set in the bleAdvPar construct. * BLE advertisements were not transmitted in intervals as specified by BLE spec.
This commit is contained in:
parent
17f4c68888
commit
c177034d39
|
@ -56,7 +56,7 @@
|
||||||
/* TI-RTOS RF Mode Object */
|
/* TI-RTOS RF Mode Object */
|
||||||
RF_Mode rf_ble_mode =
|
RF_Mode rf_ble_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_BLE,
|
.rfMode = RF_MODE_MULTIPLE,
|
||||||
.cpePatchFxn = &rf_patch_cpe_ble,
|
.cpePatchFxn = &rf_patch_cpe_ble,
|
||||||
.mcePatchFxn = 0,
|
.mcePatchFxn = 0,
|
||||||
.rfePatchFxn = &rf_patch_rfe_ble,
|
.rfePatchFxn = &rf_patch_rfe_ble,
|
||||||
|
@ -117,38 +117,6 @@ rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||||
.pRegOverride = rf_ble_overrides,
|
.pRegOverride = rf_ble_overrides,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Structure for CMD_BLE_ADV_NC.pParams */
|
|
||||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
|
||||||
{
|
|
||||||
.pRxQ = 0,
|
|
||||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
|
||||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
|
||||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
|
||||||
.rxConfig.bIncludeLenByte = 0x0,
|
|
||||||
.rxConfig.bIncludeCrc = 0x0,
|
|
||||||
.rxConfig.bAppendRssi = 0x0,
|
|
||||||
.rxConfig.bAppendStatus = 0x0,
|
|
||||||
.rxConfig.bAppendTimestamp = 0x0,
|
|
||||||
.advConfig.advFilterPolicy = 0x0,
|
|
||||||
.advConfig.deviceAddrType = 0x0,
|
|
||||||
.advConfig.peerAddrType = 0x0,
|
|
||||||
.advConfig.bStrictLenFilter = 0x0,
|
|
||||||
.advConfig.rpaMode = 0x0,
|
|
||||||
.advLen = 0x18,
|
|
||||||
.scanRspLen = 0x00,
|
|
||||||
.pAdvData = 0,
|
|
||||||
.pScanRspData = 0,
|
|
||||||
.pDeviceAddress = 0,
|
|
||||||
.pWhiteList = 0,
|
|
||||||
.__dummy0 = 0x0000,
|
|
||||||
.__dummy1 = 0x00,
|
|
||||||
.endTrigger.triggerType = TRIG_NEVER,
|
|
||||||
.endTrigger.bEnaCmd = 0x0,
|
|
||||||
.endTrigger.triggerNo = 0x0,
|
|
||||||
.endTrigger.pastTrig = 0x0,
|
|
||||||
.endTime = 0x00000000,
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* CMD_BLE_ADV_NC: BLE Non-Connectable Advertiser Command */
|
/* CMD_BLE_ADV_NC: BLE Non-Connectable Advertiser Command */
|
||||||
rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||||
{
|
{
|
||||||
|
@ -159,13 +127,13 @@ rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||||
.startTrigger.triggerType = TRIG_NOW,
|
.startTrigger.triggerType = TRIG_NOW,
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
.startTrigger.triggerNo = 0x0,
|
.startTrigger.triggerNo = 0x0,
|
||||||
.startTrigger.pastTrig = 0x0,
|
.startTrigger.pastTrig = 0x1,
|
||||||
.condition.rule = COND_NEVER,
|
.condition.rule = 0x0, /* set by driver */
|
||||||
.condition.nSkip = 0x0,
|
.condition.nSkip = 0x0,
|
||||||
.channel = 0x8C,
|
.channel = 0x00, /* set by driver */
|
||||||
.whitening.init = 0x51,
|
.whitening.init = 0x00, /* set by driver */
|
||||||
.whitening.bOverride = 0x1,
|
.whitening.bOverride = 0x1,
|
||||||
.pParams = &rf_ble_adv_par,
|
.pParams = 0x00000000, /* set by driver */
|
||||||
.pOutput = 0,
|
.pOutput = 0x00000000, /* set by driver */
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -43,7 +43,6 @@ extern RF_Mode rf_ble_mode;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API commands */
|
/* RF Core API commands */
|
||||||
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
|
||||||
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API Overrides */
|
/* RF Core API Overrides */
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
/* TI-RTOS RF Mode Object */
|
/* TI-RTOS RF Mode Object */
|
||||||
RF_Mode rf_ieee_mode =
|
RF_Mode rf_ieee_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_IEEE_15_4,
|
.rfMode = RF_MODE_MULTIPLE,
|
||||||
.cpePatchFxn = 0,
|
.cpePatchFxn = 0,
|
||||||
.mcePatchFxn = 0,
|
.mcePatchFxn = 0,
|
||||||
.rfePatchFxn = 0,
|
.rfePatchFxn = 0,
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
/* TI-RTOS RF Mode Object */
|
/* TI-RTOS RF Mode Object */
|
||||||
RF_Mode rf_prop_mode =
|
RF_Mode rf_prop_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_PROPRIETARY_SUB_1,
|
.rfMode = RF_MODE_MULTIPLE,
|
||||||
.cpePatchFxn = &rf_patch_cpe_genfsk,
|
.cpePatchFxn = &rf_patch_cpe_genfsk,
|
||||||
.mcePatchFxn = 0,
|
.mcePatchFxn = 0,
|
||||||
.rfePatchFxn = &rf_patch_rfe_genfsk,
|
.rfePatchFxn = &rf_patch_rfe_genfsk,
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_bt5.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h)
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
RF_Mode rf_ble_mode =
|
RF_Mode rf_ble_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_AUTO,
|
.rfMode = RF_MODE_AUTO,
|
||||||
.cpePatchFxn = &rf_patch_cpe_bt5,
|
.cpePatchFxn = &rf_patch_cpe_multi_protocol,
|
||||||
.mcePatchFxn = &rf_patch_mce_bt5,
|
.mcePatchFxn = &rf_patch_mce_bt5,
|
||||||
.rfePatchFxn = &rf_patch_rfe_bt5,
|
.rfePatchFxn = &rf_patch_rfe_bt5,
|
||||||
};
|
};
|
||||||
|
@ -148,60 +148,28 @@ rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||||
.pRegOverrideCoded = rf_ble_overrides_coded,
|
.pRegOverrideCoded = rf_ble_overrides_coded,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Structure for CMD_BLE5_ADV_NC.pParams */
|
|
||||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
|
||||||
{
|
|
||||||
.pRxQ = 0,
|
|
||||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
|
||||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
|
||||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
|
||||||
.rxConfig.bIncludeLenByte = 0x0,
|
|
||||||
.rxConfig.bIncludeCrc = 0x0,
|
|
||||||
.rxConfig.bAppendRssi = 0x0,
|
|
||||||
.rxConfig.bAppendStatus = 0x0,
|
|
||||||
.rxConfig.bAppendTimestamp = 0x0,
|
|
||||||
.advConfig.advFilterPolicy = 0x0,
|
|
||||||
.advConfig.deviceAddrType = 0x0,
|
|
||||||
.advConfig.peerAddrType = 0x0,
|
|
||||||
.advConfig.bStrictLenFilter = 0x0,
|
|
||||||
.advConfig.rpaMode = 0x0,
|
|
||||||
.advLen = 0x18,
|
|
||||||
.scanRspLen = 0x00,
|
|
||||||
.pAdvData = 0,
|
|
||||||
.pScanRspData = 0,
|
|
||||||
.pDeviceAddress = 0,
|
|
||||||
.pWhiteList = 0,
|
|
||||||
.__dummy0 = 0x0000,
|
|
||||||
.__dummy1 = 0x00,
|
|
||||||
.endTrigger.triggerType = TRIG_NEVER,
|
|
||||||
.endTrigger.bEnaCmd = 0x0,
|
|
||||||
.endTrigger.triggerNo = 0x0,
|
|
||||||
.endTrigger.pastTrig = 0x0,
|
|
||||||
.endTime = 0x00000000,
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
|
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
|
||||||
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||||
{
|
{
|
||||||
.commandNo = 0x182D,
|
.commandNo = CMD_BLE5_ADV_NC,
|
||||||
.status = 0x0000,
|
.status = IDLE,
|
||||||
.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
.pNextOp = 0,
|
||||||
.startTime = 0x00000000,
|
.startTime = 0x00000000,
|
||||||
.startTrigger.triggerType = 0x0,
|
.startTrigger.triggerType = TRIG_NOW,
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
.startTrigger.triggerNo = 0x0,
|
.startTrigger.triggerNo = 0x0,
|
||||||
.startTrigger.pastTrig = 0x0,
|
.startTrigger.pastTrig = 0x1,
|
||||||
.condition.rule = 0x1,
|
.condition.rule = 0x0, /* set by driver */
|
||||||
.condition.nSkip = 0x0,
|
.condition.nSkip = 0x0,
|
||||||
.channel = 0x8C,
|
.channel = 0x00, /* set by driver */
|
||||||
.whitening.init = 0x51,
|
.whitening.init = 0x00, /* set by driver */
|
||||||
.whitening.bOverride = 0x1,
|
.whitening.bOverride = 0x1,
|
||||||
.phyMode.mainMode = 0x0,
|
.phyMode.mainMode = 0x0,
|
||||||
.phyMode.coding = 0x0,
|
.phyMode.coding = 0x0,
|
||||||
.rangeDelay = 0x00,
|
.rangeDelay = 0x00,
|
||||||
.txPower = 0x0000,
|
.txPower = 0x0000,
|
||||||
.pParams = &rf_ble_adv_par,
|
.pParams = 0x00000000, /* set by driver */
|
||||||
.pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
.pOutput = 0x00000000, /* set by driver */
|
||||||
.tx20Power = 0x00000000,
|
.tx20Power = 0x00000000,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -43,7 +43,6 @@ extern RF_Mode rf_ble_mode;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API commands */
|
/* RF Core API commands */
|
||||||
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
|
||||||
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API Overrides */
|
/* RF Core API Overrides */
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ieee_802_15_4.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h)
|
||||||
|
|
||||||
#include <ti/drivers/rf/RF.h>
|
#include <ti/drivers/rf/RF.h>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
RF_Mode rf_ieee_mode =
|
RF_Mode rf_ieee_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_AUTO,
|
.rfMode = RF_MODE_AUTO,
|
||||||
.cpePatchFxn = &rf_patch_cpe_ieee_802_15_4,
|
.cpePatchFxn = &rf_patch_cpe_multi_protocol,
|
||||||
.mcePatchFxn = &rf_patch_mce_ieee_802_15_4,
|
.mcePatchFxn = &rf_patch_mce_ieee_802_15_4,
|
||||||
.rfePatchFxn = 0,
|
.rfePatchFxn = 0,
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_prop.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_genfsk.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_genfsk.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_genfsk.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_genfsk.h)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
RF_Mode rf_prop_mode =
|
RF_Mode rf_prop_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_AUTO,
|
.rfMode = RF_MODE_AUTO,
|
||||||
.cpePatchFxn = &rf_patch_cpe_prop,
|
.cpePatchFxn = &rf_patch_cpe_multi_protocol,
|
||||||
.mcePatchFxn = &rf_patch_mce_genfsk,
|
.mcePatchFxn = &rf_patch_mce_genfsk,
|
||||||
.rfePatchFxn = &rf_patch_rfe_genfsk,
|
.rfePatchFxn = &rf_patch_rfe_genfsk,
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
/* TI-RTOS RF Mode Object */
|
/* TI-RTOS RF Mode Object */
|
||||||
RF_Mode rf_ble_mode =
|
RF_Mode rf_ble_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_BLE,
|
.rfMode = RF_MODE_MULTIPLE,
|
||||||
.cpePatchFxn = &rf_patch_cpe_ble,
|
.cpePatchFxn = &rf_patch_cpe_ble,
|
||||||
.mcePatchFxn = 0,
|
.mcePatchFxn = 0,
|
||||||
.rfePatchFxn = &rf_patch_rfe_ble,
|
.rfePatchFxn = &rf_patch_rfe_ble,
|
||||||
|
@ -113,38 +113,6 @@ rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||||
.pRegOverride = rf_ble_overrides,
|
.pRegOverride = rf_ble_overrides,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Structure for CMD_BLE_ADV_NC.pParams */
|
|
||||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
|
||||||
{
|
|
||||||
.pRxQ = 0,
|
|
||||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
|
||||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
|
||||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
|
||||||
.rxConfig.bIncludeLenByte = 0x0,
|
|
||||||
.rxConfig.bIncludeCrc = 0x0,
|
|
||||||
.rxConfig.bAppendRssi = 0x0,
|
|
||||||
.rxConfig.bAppendStatus = 0x0,
|
|
||||||
.rxConfig.bAppendTimestamp = 0x0,
|
|
||||||
.advConfig.advFilterPolicy = 0x0,
|
|
||||||
.advConfig.deviceAddrType = 0x0,
|
|
||||||
.advConfig.peerAddrType = 0x0,
|
|
||||||
.advConfig.bStrictLenFilter = 0x0,
|
|
||||||
.advConfig.rpaMode = 0x0,
|
|
||||||
.advLen = 0x18,
|
|
||||||
.scanRspLen = 0x00,
|
|
||||||
.pAdvData = 0,
|
|
||||||
.pScanRspData = 0,
|
|
||||||
.pDeviceAddress = 0,
|
|
||||||
.pWhiteList = 0,
|
|
||||||
.__dummy0 = 0x0000,
|
|
||||||
.__dummy1 = 0x00,
|
|
||||||
.endTrigger.triggerType = TRIG_NEVER,
|
|
||||||
.endTrigger.bEnaCmd = 0x0,
|
|
||||||
.endTrigger.triggerNo = 0x0,
|
|
||||||
.endTrigger.pastTrig = 0x0,
|
|
||||||
.endTime = 0x00000000,
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* CMD_BLE_ADV_NC: BLE Non-Connectable Advertiser Command */
|
/* CMD_BLE_ADV_NC: BLE Non-Connectable Advertiser Command */
|
||||||
rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||||
{
|
{
|
||||||
|
@ -155,13 +123,13 @@ rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||||
.startTrigger.triggerType = TRIG_NOW,
|
.startTrigger.triggerType = TRIG_NOW,
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
.startTrigger.triggerNo = 0x0,
|
.startTrigger.triggerNo = 0x0,
|
||||||
.startTrigger.pastTrig = 0x0,
|
.startTrigger.pastTrig = 0x1,
|
||||||
.condition.rule = COND_NEVER,
|
.condition.rule = 0x0, /* set by driver */
|
||||||
.condition.nSkip = 0x0,
|
.condition.nSkip = 0x0,
|
||||||
.channel = 0x8C,
|
.channel = 0x00, /* set by driver */
|
||||||
.whitening.init = 0x51,
|
.whitening.init = 0x00, /* set by driver */
|
||||||
.whitening.bOverride = 0x1,
|
.whitening.bOverride = 0x1,
|
||||||
.pParams = &rf_ble_adv_par,
|
.pParams = 0x00000000, /* set by driver */
|
||||||
.pOutput = 0,
|
.pOutput = 0x00000000, /* set by driver */
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -43,7 +43,6 @@ extern RF_Mode rf_ble_mode;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API commands */
|
/* RF Core API commands */
|
||||||
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
extern rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
|
||||||
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
extern rfc_CMD_BLE_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API Overrides */
|
/* RF Core API Overrides */
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
/* TI-RTOS RF Mode Object */
|
/* TI-RTOS RF Mode Object */
|
||||||
RF_Mode rf_ieee_mode =
|
RF_Mode rf_ieee_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_IEEE_15_4,
|
.rfMode = RF_MODE_MULTIPLE,
|
||||||
.cpePatchFxn = &rf_patch_cpe_ieee,
|
.cpePatchFxn = &rf_patch_cpe_ieee,
|
||||||
.mcePatchFxn = 0,
|
.mcePatchFxn = 0,
|
||||||
.rfePatchFxn = 0,
|
.rfePatchFxn = 0,
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_bt5.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_bt5.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_bt5.h)
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
RF_Mode rf_ble_mode =
|
RF_Mode rf_ble_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_AUTO,
|
.rfMode = RF_MODE_AUTO,
|
||||||
.cpePatchFxn = &rf_patch_cpe_bt5,
|
.cpePatchFxn = &rf_patch_cpe_multi_protocol,
|
||||||
.mcePatchFxn = &rf_patch_mce_bt5,
|
.mcePatchFxn = &rf_patch_mce_bt5,
|
||||||
.rfePatchFxn = &rf_patch_rfe_bt5,
|
.rfePatchFxn = &rf_patch_rfe_bt5,
|
||||||
};
|
};
|
||||||
|
@ -148,60 +148,28 @@ rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup =
|
||||||
.pRegOverrideCoded = rf_ble_overrides_coded,
|
.pRegOverrideCoded = rf_ble_overrides_coded,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Structure for CMD_BLE5_ADV_NC.pParams */
|
|
||||||
rfc_bleAdvPar_t rf_ble_adv_par =
|
|
||||||
{
|
|
||||||
.pRxQ = 0,
|
|
||||||
.rxConfig.bAutoFlushIgnored = 0x0,
|
|
||||||
.rxConfig.bAutoFlushCrcErr = 0x0,
|
|
||||||
.rxConfig.bAutoFlushEmpty = 0x0,
|
|
||||||
.rxConfig.bIncludeLenByte = 0x0,
|
|
||||||
.rxConfig.bIncludeCrc = 0x0,
|
|
||||||
.rxConfig.bAppendRssi = 0x0,
|
|
||||||
.rxConfig.bAppendStatus = 0x0,
|
|
||||||
.rxConfig.bAppendTimestamp = 0x0,
|
|
||||||
.advConfig.advFilterPolicy = 0x0,
|
|
||||||
.advConfig.deviceAddrType = 0x0,
|
|
||||||
.advConfig.peerAddrType = 0x0,
|
|
||||||
.advConfig.bStrictLenFilter = 0x0,
|
|
||||||
.advConfig.rpaMode = 0x0,
|
|
||||||
.advLen = 0x18,
|
|
||||||
.scanRspLen = 0x00,
|
|
||||||
.pAdvData = 0,
|
|
||||||
.pScanRspData = 0,
|
|
||||||
.pDeviceAddress = 0,
|
|
||||||
.pWhiteList = 0,
|
|
||||||
.__dummy0 = 0x0000,
|
|
||||||
.__dummy1 = 0x00,
|
|
||||||
.endTrigger.triggerType = TRIG_NEVER,
|
|
||||||
.endTrigger.bEnaCmd = 0x0,
|
|
||||||
.endTrigger.triggerNo = 0x0,
|
|
||||||
.endTrigger.pastTrig = 0x0,
|
|
||||||
.endTime = 0x00000000,
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
|
/* CMD_BLE5_ADV_NC: Bluetooth 5 Non-Connectable Advertiser Command */
|
||||||
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc =
|
||||||
{
|
{
|
||||||
.commandNo = 0x182D,
|
.commandNo = CMD_BLE5_ADV_NC,
|
||||||
.status = 0x0000,
|
.status = IDLE,
|
||||||
.pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
.pNextOp = 0,
|
||||||
.startTime = 0x00000000,
|
.startTime = 0x00000000,
|
||||||
.startTrigger.triggerType = 0x0,
|
.startTrigger.triggerType = TRIG_NOW,
|
||||||
.startTrigger.bEnaCmd = 0x0,
|
.startTrigger.bEnaCmd = 0x0,
|
||||||
.startTrigger.triggerNo = 0x0,
|
.startTrigger.triggerNo = 0x0,
|
||||||
.startTrigger.pastTrig = 0x0,
|
.startTrigger.pastTrig = 0x1,
|
||||||
.condition.rule = 0x1,
|
.condition.rule = 0x0, /* set by driver */
|
||||||
.condition.nSkip = 0x0,
|
.condition.nSkip = 0x0,
|
||||||
.channel = 0x8C,
|
.channel = 0x00, /* set by driver */
|
||||||
.whitening.init = 0x51,
|
.whitening.init = 0x00, /* set by driver */
|
||||||
.whitening.bOverride = 0x1,
|
.whitening.bOverride = 0x1,
|
||||||
.phyMode.mainMode = 0x0,
|
.phyMode.mainMode = 0x0,
|
||||||
.phyMode.coding = 0x0,
|
.phyMode.coding = 0x0,
|
||||||
.rangeDelay = 0x00,
|
.rangeDelay = 0x00,
|
||||||
.txPower = 0x0000,
|
.txPower = 0x0000,
|
||||||
.pParams = &rf_ble_adv_par,
|
.pParams = 0x00000000, /* set by driver */
|
||||||
.pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
|
.pOutput = 0x00000000, /* set by driver */
|
||||||
.tx20Power = 0x00000000,
|
.tx20Power = 0x00000000,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -43,7 +43,6 @@ extern RF_Mode rf_ble_mode;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API commands */
|
/* RF Core API commands */
|
||||||
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
extern rfc_CMD_BLE5_RADIO_SETUP_t rf_ble_cmd_radio_setup;
|
||||||
extern rfc_bleAdvPar_t rf_ble_adv_par;
|
|
||||||
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
extern rfc_CMD_BLE5_ADV_NC_t rf_ble_cmd_ble_adv_nc;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* RF Core API Overrides */
|
/* RF Core API Overrides */
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ieee_802_15_4.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_multi_protocol.h)
|
||||||
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h)
|
#include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ieee_802_15_4.h)
|
||||||
|
|
||||||
#include <ti/drivers/rf/RF.h>
|
#include <ti/drivers/rf/RF.h>
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
RF_Mode rf_ieee_mode =
|
RF_Mode rf_ieee_mode =
|
||||||
{
|
{
|
||||||
.rfMode = RF_MODE_AUTO,
|
.rfMode = RF_MODE_AUTO,
|
||||||
.cpePatchFxn = &rf_patch_cpe_ieee_802_15_4,
|
.cpePatchFxn = &rf_patch_cpe_multi_protocol,
|
||||||
.mcePatchFxn = &rf_patch_mce_ieee_802_15_4,
|
.mcePatchFxn = &rf_patch_mce_ieee_802_15_4,
|
||||||
.rfePatchFxn = 0,
|
.rfePatchFxn = 0,
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,7 @@ ble_addr_ptr(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
ble_addr_cpy(uint8_t *dst)
|
ble_addr_be_cpy(uint8_t *dst)
|
||||||
{
|
{
|
||||||
if(!dst) {
|
if(!dst) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -102,6 +102,23 @@ ble_addr_cpy(uint8_t *dst)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
|
ble_addr_le_cpy(uint8_t *dst)
|
||||||
|
{
|
||||||
|
if(!dst) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile const uint8_t *const ble_addr = ble_addr_ptr();
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
for(i = 0; i < BLE_ADDR_SIZE; i++) {
|
||||||
|
dst[i] = ble_addr[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
int
|
||||||
ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
|
ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
|
||||||
{
|
{
|
||||||
if(!dst || !src) {
|
if(!dst || !src) {
|
||||||
|
@ -126,7 +143,7 @@ ble_addr_to_eui64_cpy(uint8_t *dst)
|
||||||
int res;
|
int res;
|
||||||
uint8_t ble_addr[BLE_ADDR_SIZE];
|
uint8_t ble_addr[BLE_ADDR_SIZE];
|
||||||
|
|
||||||
res = ble_addr_cpy(ble_addr);
|
res = ble_addr_le_cpy(ble_addr);
|
||||||
if(res) {
|
if(res) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ uint8_t *ble_addr_ptr(void);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \brief Copy the node's factory BLE address to a destination memory area
|
* \brief Copy the node's factory BLE address to a destination memory area
|
||||||
|
* in big-endian (be) order.
|
||||||
* \param dst A pointer to the destination area where the BLE address is to be
|
* \param dst A pointer to the destination area where the BLE address is to be
|
||||||
* written
|
* written
|
||||||
* \return 0 : Returned successfully
|
* \return 0 : Returned successfully
|
||||||
|
@ -68,7 +69,21 @@ uint8_t *ble_addr_ptr(void);
|
||||||
* the process. The factory address on devices is normally little-endian,
|
* the process. The factory address on devices is normally little-endian,
|
||||||
* therefore you should expect dst to store the address in a big-endian order.
|
* therefore you should expect dst to store the address in a big-endian order.
|
||||||
*/
|
*/
|
||||||
int ble_addr_cpy(uint8_t *dst);
|
int ble_addr_be_cpy(uint8_t *dst);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \brief Copy the node's factory BLE address to a destination memory area
|
||||||
|
* in little-endian (le) order.
|
||||||
|
* \param dst A pointer to the destination area where the BLE address is to be
|
||||||
|
* written
|
||||||
|
* \return 0 : Returned successfully
|
||||||
|
* -1 : Returned with error
|
||||||
|
*
|
||||||
|
* This function will copy 6 bytes, but will **not** invert the byte order.
|
||||||
|
* This is usefull for the RF core which assumes the BLE MAC address in
|
||||||
|
* little-endian order.
|
||||||
|
*/
|
||||||
|
int ble_addr_le_cpy(uint8_t *dst);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \brief Copy the node's BLE address to a destination memory area and converts
|
* \brief Copy the node's BLE address to a destination memory area and converts
|
||||||
|
|
|
@ -70,32 +70,58 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if RF_CONF_BLE_BEACON_ENABLE
|
#if RF_CONF_BLE_BEACON_ENABLE
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* BLE Advertisement channels. Not to be changed by the user. */
|
|
||||||
typedef enum {
|
|
||||||
BLE_ADV_CHANNEL_37 = (1 << 0),
|
|
||||||
BLE_ADV_CHANNEL_38 = (1 << 1),
|
|
||||||
BLE_ADV_CHANNEL_39 = (1 << 2),
|
|
||||||
|
|
||||||
BLE_ADV_CHANNEL_ALL = (BLE_ADV_CHANNEL_37 |
|
|
||||||
BLE_ADV_CHANNEL_38 |
|
|
||||||
BLE_ADV_CHANNEL_39),
|
|
||||||
} ble_adv_channel_t;
|
|
||||||
|
|
||||||
#define BLE_ADV_CHANNEL_MIN 37
|
|
||||||
#define BLE_ADV_CHANNEL_MAX 39
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* Maximum BLE advertisement size. Not to be changed by the user. */
|
/* Maximum BLE advertisement size. Not to be changed by the user. */
|
||||||
#define BLE_ADV_MAX_SIZE 31
|
#define BLE_ADV_MAX_SIZE 31
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* BLE Intervals: Send a burst of advertisements every BLE_ADV_INTERVAL secs */
|
/*
|
||||||
#define BLE_ADV_INTERVAL (CLOCK_SECOND * 5)
|
* BLE Intervals: Send a burst of advertisements every BLE_ADV_INTERVAL
|
||||||
#define BLE_ADV_DUTY_CYCLE (CLOCK_SECOND / 10)
|
* specified in milliseconds.
|
||||||
#define BLE_ADV_MESSAGES 10
|
*/
|
||||||
|
#define BLE_ADV_INTERVAL ((100 * CLOCK_SECOND) / 1000)
|
||||||
|
|
||||||
|
/* GAP Advertisement data types */
|
||||||
|
#define BLE_ADV_TYPE_FLAGS 0x01
|
||||||
|
#define BLE_ADV_TYPE_16BIT_MORE 0x02
|
||||||
|
#define BLE_ADV_TYPE_16BIT_COMPLETE 0x03
|
||||||
|
#define BLE_ADV_TYPE_32BIT_MORE 0x04
|
||||||
|
#define BLE_ADV_TYPE_32BIT_COMPLETE 0x05
|
||||||
|
#define BLE_ADV_TYPE_128BIT_MORE 0x06
|
||||||
|
#define BLE_ADV_TYPE_128BIT_COMPLETE 0x07
|
||||||
|
#define BLE_ADV_TYPE_LOCAL_NAME_SHORT 0x08
|
||||||
|
#define BLE_ADV_TYPE_LOCAL_NAME_COMPLETE 0x09
|
||||||
|
#define BLE_ADV_TYPE_POWER_LEVEL 0x0A
|
||||||
|
#define BLE_ADV_TYPE_OOB_CLASS_OF_DEVICE 0x0D
|
||||||
|
#define BLE_ADV_TYPE_OOB_SIMPLE_PAIRING_HASHC 0x0E
|
||||||
|
#define BLE_ADV_TYPE_OOB_SIMPLE_PAIRING_RANDR 0x0F
|
||||||
|
#define BLE_ADV_TYPE_SM_TK 0x10
|
||||||
|
#define BLE_ADV_TYPE_SM_OOB_FLAG 0x11
|
||||||
|
#define BLE_ADV_TYPE_SLAVE_CONN_INTERVAL_RANGE 0x12
|
||||||
|
#define BLE_ADV_TYPE_SIGNED_DATA 0x13
|
||||||
|
#define BLE_ADV_TYPE_SERVICE_LIST_16BIT 0x14
|
||||||
|
#define BLE_ADV_TYPE_SERVICE_LIST_128BIT 0x15
|
||||||
|
#define BLE_ADV_TYPE_SERVICE_DATA 0x16
|
||||||
|
#define BLE_ADV_TYPE_PUBLIC_TARGET_ADDR 0x17
|
||||||
|
#define BLE_ADV_TYPE_RANDOM_TARGET_ADDR 0x18
|
||||||
|
#define BLE_ADV_TYPE_APPEARANCE 0x19
|
||||||
|
#define BLE_ADV_TYPE_ADV_INTERVAL 0x1A
|
||||||
|
#define BLE_ADV_TYPE_LE_BD_ADDR 0x1B
|
||||||
|
#define BLE_ADV_TYPE_LE_ROLE 0x1C
|
||||||
|
#define BLE_ADV_TYPE_SIMPLE_PAIRING_HASHC_256 0x1D
|
||||||
|
#define BLE_ADV_TYPE_SIMPLE_PAIRING_RANDR_256 0x1E
|
||||||
|
#define BLE_ADV_TYPE_SERVICE_DATA_32BIT 0x20
|
||||||
|
#define BLE_ADV_TYPE_SERVICE_DATA_128BIT 0x21
|
||||||
|
#define BLE_ADV_TYPE_3D_INFO_DATA 0x3D
|
||||||
|
#define BLE_ADV_TYPE_MANUFACTURER_SPECIFIC 0xFF
|
||||||
|
|
||||||
|
/* GAP Advertisement data type flags */
|
||||||
|
|
||||||
|
/* Discovery Mode: LE Limited Discoverable Mode */
|
||||||
|
#define BLE_ADV_TYPE_FLAGS_LIMITED 0x01
|
||||||
|
/* Discovery Mode: LE General Discoverable Mode */
|
||||||
|
#define BLE_ADV_TYPE_FLAGS_GENERAL 0x02
|
||||||
|
/* Discovery Mode: BR/EDR Not Supported */
|
||||||
|
#define BLE_ADV_TYPE_FLAGS_BREDR_NOT_SUPPORTED 0x04
|
||||||
|
|
||||||
/* BLE Advertisement-related macros */
|
|
||||||
#define BLE_ADV_TYPE_DEVINFO 0x01
|
|
||||||
#define BLE_ADV_TYPE_NAME 0x09
|
|
||||||
#define BLE_ADV_TYPE_MANUFACTURER 0xFF
|
|
||||||
#define BLE_ADV_NAME_BUF_LEN BLE_ADV_MAX_SIZE
|
#define BLE_ADV_NAME_BUF_LEN BLE_ADV_MAX_SIZE
|
||||||
#define BLE_ADV_PAYLOAD_BUF_LEN 64
|
#define BLE_ADV_PAYLOAD_BUF_LEN 64
|
||||||
#define BLE_UUID_SIZE 16
|
#define BLE_UUID_SIZE 16
|
||||||
|
@ -117,6 +143,11 @@ typedef struct {
|
||||||
|
|
||||||
/* RF driver */
|
/* RF driver */
|
||||||
RF_Handle rf_handle;
|
RF_Handle rf_handle;
|
||||||
|
|
||||||
|
/* BLE command specific structures. Common accross BLE and BLE5. */
|
||||||
|
uint8_t ble_mac_addr[6];
|
||||||
|
rfc_bleAdvPar_t ble_adv_par;
|
||||||
|
rfc_bleAdvOutput_t ble_adv_output;
|
||||||
} ble_beacond_t;
|
} ble_beacond_t;
|
||||||
|
|
||||||
static ble_beacond_t ble_beacond;
|
static ble_beacond_t ble_beacond;
|
||||||
|
@ -126,13 +157,10 @@ PROCESS(ble_beacond_process, "RF BLE Beacon Daemon Process");
|
||||||
rf_ble_beacond_result_t
|
rf_ble_beacond_result_t
|
||||||
rf_ble_beacond_init(void)
|
rf_ble_beacond_init(void)
|
||||||
{
|
{
|
||||||
ble_adv_par.pDeviceAddress = (uint16_t *)ble_addr_ptr();
|
|
||||||
|
|
||||||
RF_Params rf_params;
|
RF_Params rf_params;
|
||||||
RF_Params_init(&rf_params);
|
RF_Params_init(&rf_params);
|
||||||
|
|
||||||
/* Should immediately turn off radio if possible */
|
rf_params.nInactivityTimeout = RF_CONF_INACTIVITY_TIMEOUT;
|
||||||
rf_params.nInactivityTimeout = 0;
|
|
||||||
|
|
||||||
ble_beacond.rf_handle = ble_open(&rf_params);
|
ble_beacond.rf_handle = ble_open(&rf_params);
|
||||||
|
|
||||||
|
@ -140,6 +168,18 @@ rf_ble_beacond_init(void)
|
||||||
return RF_BLE_BEACOND_ERROR;
|
return RF_BLE_BEACOND_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It is important that the contents of the BLE MAC address is copied into
|
||||||
|
* RAM, as the System CPU, and subsequently flash, goes idle when pending
|
||||||
|
* on an RF command. This causes pend to hang forever.
|
||||||
|
*/
|
||||||
|
ble_addr_le_cpy(ble_beacond.ble_mac_addr);
|
||||||
|
ble_beacond.ble_adv_par.pDeviceAddress = (uint16_t *)ble_beacond.ble_mac_addr;
|
||||||
|
ble_beacond.ble_adv_par.endTrigger.triggerType = TRIG_NEVER;
|
||||||
|
|
||||||
|
rf_ble_cmd_ble_adv_nc.pParams = &ble_beacond.ble_adv_par;
|
||||||
|
rf_ble_cmd_ble_adv_nc.pOutput = &ble_beacond.ble_adv_output;
|
||||||
|
|
||||||
return RF_BLE_BEACOND_OK;
|
return RF_BLE_BEACOND_OK;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -154,12 +194,14 @@ rf_ble_beacond_config(clock_time_t interval, const char *name)
|
||||||
ble_beacond.ble_adv_interval = interval;
|
ble_beacond.ble_adv_interval = interval;
|
||||||
|
|
||||||
res = RF_BLE_BEACOND_OK;
|
res = RF_BLE_BEACOND_OK;
|
||||||
|
} else {
|
||||||
|
ble_beacond.ble_adv_interval = BLE_ADV_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name != NULL) {
|
if(name != NULL) {
|
||||||
const size_t name_len = strlen(name);
|
const size_t name_len = strlen(name);
|
||||||
|
|
||||||
if((name_len == 0) || (name_len >= BLE_ADV_NAME_BUF_LEN)) {
|
if((0 < name_len) && (name_len < BLE_ADV_NAME_BUF_LEN)) {
|
||||||
ble_beacond.adv_name_len = name_len;
|
ble_beacond.adv_name_len = name_len;
|
||||||
memcpy(ble_beacond.adv_name, name, name_len);
|
memcpy(ble_beacond.adv_name, name, name_len);
|
||||||
|
|
||||||
|
@ -235,37 +277,9 @@ rf_ble_get_tx_power(void)
|
||||||
return dbm;
|
return dbm;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static rf_ble_beacond_result_t
|
|
||||||
ble_beacon_burst(uint8_t channels_bm, uint8_t *data, uint8_t len)
|
|
||||||
{
|
|
||||||
rf_result_t res;
|
|
||||||
|
|
||||||
uint8_t channel;
|
|
||||||
for(channel = BLE_ADV_CHANNEL_MIN; channel <= BLE_ADV_CHANNEL_MAX; ++channel) {
|
|
||||||
const uint8_t channel_bv = (1 << (channel - BLE_ADV_CHANNEL_MIN));
|
|
||||||
if((channel_bv & channels_bm) == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ble_adv_par.advLen = len;
|
|
||||||
ble_adv_par.pAdvData = data;
|
|
||||||
|
|
||||||
ble_cmd_beacon.channel = channel;
|
|
||||||
|
|
||||||
res = ble_sched_beacon(NULL, 0);
|
|
||||||
|
|
||||||
if(res != RF_RESULT_OK) {
|
|
||||||
return RF_BLE_BEACOND_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return RF_BLE_BEACOND_OK;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
PROCESS_THREAD(ble_beacond_process, ev, data)
|
PROCESS_THREAD(ble_beacond_process, ev, data)
|
||||||
{
|
{
|
||||||
static size_t i;
|
size_t len;
|
||||||
static size_t len;
|
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
@ -278,30 +292,33 @@ PROCESS_THREAD(ble_beacond_process, ev, data)
|
||||||
PROCESS_EXIT();
|
PROCESS_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Device info */
|
||||||
/* Set the adv payload each pass: The device name may have changed */
|
/* Set the adv payload each pass: The device name may have changed */
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
/* Device info */
|
#define append_byte(x) ble_beacond.tx_buf[len++] = (uint8_t)((x))
|
||||||
ble_beacond.tx_buf[len++] = (uint8_t)0x02; /* 2 bytes */
|
|
||||||
ble_beacond.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_DEVINFO;
|
/* 2 bytes */
|
||||||
ble_beacond.tx_buf[len++] = (uint8_t)0x1A; /* LE general discoverable + BR/EDR */
|
append_byte(2);
|
||||||
ble_beacond.tx_buf[len++] = (uint8_t)ble_beacond.adv_name_len;
|
append_byte(BLE_ADV_TYPE_FLAGS);
|
||||||
ble_beacond.tx_buf[len++] = (uint8_t)BLE_ADV_TYPE_NAME;
|
/* LE general discoverable + BR/EDR not supported */
|
||||||
|
append_byte(BLE_ADV_TYPE_FLAGS_GENERAL |
|
||||||
|
BLE_ADV_TYPE_FLAGS_BREDR_NOT_SUPPORTED);
|
||||||
|
|
||||||
|
/* 1 + len(name) bytes (excluding zero termination) */
|
||||||
|
append_byte(1 + ble_beacond.adv_name_len);
|
||||||
|
append_byte(BLE_ADV_TYPE_LOCAL_NAME_COMPLETE);
|
||||||
|
|
||||||
memcpy(ble_beacond.tx_buf + len, ble_beacond.adv_name, ble_beacond.adv_name_len);
|
memcpy(ble_beacond.tx_buf + len, ble_beacond.adv_name, ble_beacond.adv_name_len);
|
||||||
len += ble_beacond.adv_name_len;
|
len += ble_beacond.adv_name_len;
|
||||||
|
|
||||||
/*
|
#undef append_byte
|
||||||
* Send BLE_ADV_MESSAGES beacon bursts. Each burst on all three
|
|
||||||
* channels, with a BLE_ADV_DUTY_CYCLE interval between bursts
|
|
||||||
*/
|
|
||||||
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, ble_beacond.tx_buf, len);
|
|
||||||
for(i = 1; i < BLE_ADV_MESSAGES; ++i) {
|
|
||||||
etimer_set(&ble_beacond.ble_adv_et, BLE_ADV_DUTY_CYCLE);
|
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&ble_beacond.ble_adv_et));
|
|
||||||
|
|
||||||
ble_beacon_burst(BLE_ADV_CHANNEL_ALL, ble_beacond.tx_buf, len);
|
/* Send advertisements on all three channels */
|
||||||
}
|
ble_beacond.ble_adv_par.advLen = len;
|
||||||
|
ble_beacond.ble_adv_par.pAdvData = ble_beacond.tx_buf;
|
||||||
|
|
||||||
|
ble_sched_beacons(BLE_ADV_CHANNEL_ALL);
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,32 +550,42 @@ read(void *buf, unsigned short buf_len)
|
||||||
static rf_result_t
|
static rf_result_t
|
||||||
cca_request(cmd_cca_req_t *cmd_cca_req)
|
cca_request(cmd_cca_req_t *cmd_cca_req)
|
||||||
{
|
{
|
||||||
|
RF_Stat stat = RF_StatRadioInactiveError;
|
||||||
rf_result_t res;
|
rf_result_t res;
|
||||||
|
bool stop_rx = false;
|
||||||
|
|
||||||
const bool rx_is_idle = !rx_is_active();
|
/* RX is required to be running in order to do a CCA request */
|
||||||
|
if(!rx_is_active()) {
|
||||||
|
/* If RX is not pending, i.e. soon to be running, schedule the RX command */
|
||||||
|
if(cmd_rx.status != PENDING) {
|
||||||
|
res = netstack_sched_rx(false);
|
||||||
|
if(res != RF_RESULT_OK) {
|
||||||
|
LOG_ERR("CCA request failed to schedule RX\n");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
if(rx_is_idle) {
|
/* We only stop RX if we had to schedule it */
|
||||||
res = netstack_sched_rx(false);
|
stop_rx = true;
|
||||||
if(res != RF_RESULT_OK) {
|
}
|
||||||
|
|
||||||
|
/* Make sure RX is running before we continue, unless we timeout and fail */
|
||||||
|
RTIMER_BUSYWAIT_UNTIL(!rx_is_active(), TIMEOUT_ENTER_RX_WAIT);
|
||||||
|
|
||||||
|
if(!rx_is_active()) {
|
||||||
|
LOG_ERR("CCA request failed to turn on RX, RX status=0x%04X\n", cmd_rx.status);
|
||||||
return RF_RESULT_ERROR;
|
return RF_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rtimer_clock_t t0 = RTIMER_NOW();
|
/* Perform the CCA request */
|
||||||
while((cmd_rx.status != ACTIVE) &&
|
stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t *)&cmd_cca_req);
|
||||||
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_ENTER_RX_WAIT)) ;
|
|
||||||
|
|
||||||
RF_Stat stat = RF_StatRadioInactiveError;
|
if(stop_rx) {
|
||||||
if(rx_is_active()) {
|
|
||||||
stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t *)&cmd_cca_req);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rx_is_idle) {
|
|
||||||
netstack_stop_rx();
|
netstack_stop_rx();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stat != RF_StatCmdDoneSuccess) {
|
if(stat != RF_StatCmdDoneSuccess) {
|
||||||
LOG_ERR("CCA request failed, stat=0x%02X\n", stat);
|
LOG_ERR("CCA request command failed, stat=0x%02X\n", stat);
|
||||||
return RF_RESULT_ERROR;
|
return RF_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,26 +207,36 @@ static int8_t
|
||||||
get_rssi(void)
|
get_rssi(void)
|
||||||
{
|
{
|
||||||
rf_result_t res;
|
rf_result_t res;
|
||||||
|
bool stop_rx = false;
|
||||||
|
int8_t rssi = RF_GET_RSSI_ERROR_VAL;
|
||||||
|
|
||||||
const bool rx_is_idle = !rx_is_active();
|
/* RX is required to be running in order to do a RSSI measurement */
|
||||||
|
if(!rx_is_active()) {
|
||||||
|
/* If RX is not pending, i.e. soon to be running, schedule the RX command */
|
||||||
|
if(cmd_rx.status != PENDING) {
|
||||||
|
res = netstack_sched_rx(false);
|
||||||
|
if(res != RF_RESULT_OK) {
|
||||||
|
LOG_ERR("RSSI measurement failed to schedule RX\n");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
if(rx_is_idle) {
|
/* We only stop RX if we had to schedule it */
|
||||||
res = netstack_sched_rx(false);
|
stop_rx = true;
|
||||||
if(res != RF_RESULT_OK) {
|
}
|
||||||
return RF_GET_RSSI_ERROR_VAL;
|
|
||||||
|
/* Make sure RX is running before we continue, unless we timeout and fail */
|
||||||
|
RTIMER_BUSYWAIT_UNTIL(!rx_is_active(), TIMEOUT_ENTER_RX_WAIT);
|
||||||
|
|
||||||
|
if(!rx_is_active()) {
|
||||||
|
LOG_ERR("RSSI measurement failed to turn on RX, RX status=0x%04X\n", cmd_rx.status);
|
||||||
|
return RF_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rtimer_clock_t t0 = RTIMER_NOW();
|
/* Perform the RSSI measurement */
|
||||||
while((cmd_rx.status != ACTIVE) &&
|
rssi = RF_getRssi(prop_radio.rf_handle);
|
||||||
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + TIMEOUT_ENTER_RX_WAIT)) ;
|
|
||||||
|
|
||||||
int8_t rssi = RF_GET_RSSI_ERROR_VAL;
|
if(stop_rx) {
|
||||||
if(rx_is_active()) {
|
|
||||||
rssi = RF_getRssi(prop_radio.rf_handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rx_is_idle) {
|
|
||||||
netstack_stop_rx();
|
netstack_stop_rx();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include <ti/devices/DeviceFamily.h>
|
#include <ti/devices/DeviceFamily.h>
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
|
||||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||||
|
#include DeviceFamily_constructPath(driverlib/rf_ble_mailbox.h)
|
||||||
|
|
||||||
#include <ti/drivers/rf/RF.h>
|
#include <ti/drivers/rf/RF.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -68,8 +69,6 @@
|
||||||
#define LOG_MODULE "Radio"
|
#define LOG_MODULE "Radio"
|
||||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Configuration parameters */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#define CMD_FS_RETRIES 3
|
#define CMD_FS_RETRIES 3
|
||||||
|
|
||||||
#define RF_EVENTS_CMD_DONE (RF_EventCmdDone | RF_EventLastCmdDone | \
|
#define RF_EVENTS_CMD_DONE (RF_EventCmdDone | RF_EventLastCmdDone | \
|
||||||
|
@ -82,6 +81,13 @@
|
||||||
|
|
||||||
#define EVENTS_CMD_DONE(events) (((events) & RF_EVENTS_CMD_DONE) != 0)
|
#define EVENTS_CMD_DONE(events) (((events) & RF_EVENTS_CMD_DONE) != 0)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* BLE advertisement channel range (inclusive) */
|
||||||
|
#define BLE_ADV_CHANNEL_MIN 37
|
||||||
|
#define BLE_ADV_CHANNEL_MAX 39
|
||||||
|
|
||||||
|
/* Number of BLE advertisement channels */
|
||||||
|
#define NUM_BLE_ADV_CHANNELS (BLE_ADV_CHANNEL_MAX - BLE_ADV_CHANNEL_MIN + 1)
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Synth re-calibration every 3 minutes */
|
/* Synth re-calibration every 3 minutes */
|
||||||
#define SYNTH_RECAL_INTERVAL (CLOCK_SECOND * 60 * 3)
|
#define SYNTH_RECAL_INTERVAL (CLOCK_SECOND * 60 * 3)
|
||||||
/* Set re-calibration interval with a jitter of 10 seconds */
|
/* Set re-calibration interval with a jitter of 10 seconds */
|
||||||
|
@ -89,6 +95,12 @@
|
||||||
|
|
||||||
static struct etimer synth_recal_timer;
|
static struct etimer synth_recal_timer;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
|
||||||
|
typedef rfc_CMD_BLE_ADV_NC_t ble_cmd_adv_nc_t;
|
||||||
|
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
||||||
|
typedef rfc_CMD_BLE5_ADV_NC_t ble_cmd_adv_nc_t;
|
||||||
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static RF_Object rf_netstack;
|
static RF_Object rf_netstack;
|
||||||
|
|
||||||
#if RF_CONF_BLE_BEACON_ENABLE
|
#if RF_CONF_BLE_BEACON_ENABLE
|
||||||
|
@ -479,45 +491,171 @@ ble_open(RF_Params *params)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#if RF_CONF_BLE_BEACON_ENABLE
|
||||||
|
static RF_Op *
|
||||||
|
init_ble_adv_array(ble_cmd_adv_nc_t *ble_adv_array, uint8_t bm_channel)
|
||||||
|
{
|
||||||
|
RF_Op *first_ble_adv = NULL;
|
||||||
|
ble_cmd_adv_nc_t *cmd_adv_37 = &ble_adv_array[0];
|
||||||
|
ble_cmd_adv_nc_t *cmd_adv_38 = &ble_adv_array[1];
|
||||||
|
ble_cmd_adv_nc_t *cmd_adv_39 = &ble_adv_array[2];
|
||||||
|
|
||||||
|
/* Setup channel 37 advertisement if enabled */
|
||||||
|
if(bm_channel & BLE_ADV_CHANNEL_37) {
|
||||||
|
/* Default configurations from ble_cmd_adv_nc */
|
||||||
|
memcpy(cmd_adv_37, &ble_cmd_adv_nc, sizeof(ble_cmd_adv_nc));
|
||||||
|
|
||||||
|
cmd_adv_37->channel = 37;
|
||||||
|
/* Magic number: initialization for whitener, specific for channel 37 */
|
||||||
|
cmd_adv_37->whitening.init = 0x65;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The next advertisement is chained depending on whether they are
|
||||||
|
* enbled or not. If both 38 and 39 are disabled, then there is no
|
||||||
|
* chaining.
|
||||||
|
*/
|
||||||
|
if(bm_channel & BLE_ADV_CHANNEL_38) {
|
||||||
|
cmd_adv_37->pNextOp = (RF_Op *)cmd_adv_38;
|
||||||
|
cmd_adv_37->condition.rule = COND_ALWAYS;
|
||||||
|
} else if(bm_channel & BLE_ADV_CHANNEL_39) {
|
||||||
|
cmd_adv_37->pNextOp = (RF_Op *)cmd_adv_39;
|
||||||
|
cmd_adv_37->condition.rule = COND_ALWAYS;
|
||||||
|
} else {
|
||||||
|
cmd_adv_37->pNextOp = NULL;
|
||||||
|
cmd_adv_37->condition.rule = COND_NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Channel 37 will always be first if enabled */
|
||||||
|
first_ble_adv = (RF_Op *)cmd_adv_37;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup channel 38 advertisement if enabled */
|
||||||
|
if(bm_channel & BLE_ADV_CHANNEL_38) {
|
||||||
|
memcpy(cmd_adv_38, &ble_cmd_adv_nc, sizeof(ble_cmd_adv_nc));
|
||||||
|
|
||||||
|
cmd_adv_38->channel = 38;
|
||||||
|
/* Magic number: initialization for whitener, specific for channel 38 */
|
||||||
|
cmd_adv_38->whitening.init = 0x66;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The next advertisement is chained depending on whether they are
|
||||||
|
* enbled or not. If 39 is disabled, then there is no chaining.
|
||||||
|
*/
|
||||||
|
if(bm_channel & BLE_ADV_CHANNEL_39) {
|
||||||
|
cmd_adv_38->pNextOp = (RF_Op *)cmd_adv_39;
|
||||||
|
cmd_adv_38->condition.rule = COND_ALWAYS;
|
||||||
|
} else {
|
||||||
|
cmd_adv_38->pNextOp = NULL;
|
||||||
|
cmd_adv_38->condition.rule = COND_NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Channel 38 is only first if the first_ble_adv pointer is not
|
||||||
|
* set by channel 37.
|
||||||
|
*/
|
||||||
|
if(first_ble_adv == NULL) {
|
||||||
|
first_ble_adv = (RF_Op *)cmd_adv_38;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup channel 39 advertisement if enabled */
|
||||||
|
if(bm_channel & BLE_ADV_CHANNEL_39) {
|
||||||
|
memcpy(cmd_adv_39, &ble_cmd_adv_nc, sizeof(ble_cmd_adv_nc));
|
||||||
|
|
||||||
|
cmd_adv_39->channel = 39;
|
||||||
|
/* Magic number: initialization for whitener, specific for channel 39 */
|
||||||
|
cmd_adv_39->whitening.init = 0x67;
|
||||||
|
|
||||||
|
/* Channel 39 is always the last advertisement in the chain */
|
||||||
|
cmd_adv_39->pNextOp = NULL;
|
||||||
|
cmd_adv_39->condition.rule = COND_NEVER;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Channel 39 is only first if the first_ble_adv pointer is not
|
||||||
|
* set by channel 37 or channel 38.
|
||||||
|
*/
|
||||||
|
if(first_ble_adv == NULL) {
|
||||||
|
first_ble_adv = (RF_Op *)cmd_adv_39;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return first_ble_adv;
|
||||||
|
}
|
||||||
|
#endif /* RF_CONF_BLE_BEACON_ENABLE */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
rf_result_t
|
rf_result_t
|
||||||
ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
|
ble_sched_beacons(uint8_t bm_channel)
|
||||||
{
|
{
|
||||||
#if RF_CONF_BLE_BEACON_ENABLE
|
#if RF_CONF_BLE_BEACON_ENABLE
|
||||||
RF_ScheduleCmdParams sched_params;
|
/*
|
||||||
RF_ScheduleCmdParams_init(&sched_params);
|
* Allocate the advertisement commands on the stack rather than statically
|
||||||
|
* to RAM in order to save space. We don't need them after the
|
||||||
|
* advertisements have been transmitted.
|
||||||
|
*/
|
||||||
|
ble_cmd_adv_nc_t ble_cmd_adv_nc_array[NUM_BLE_ADV_CHANNELS];
|
||||||
|
|
||||||
|
RF_Op *initial_adv = NULL;
|
||||||
|
RF_ScheduleCmdParams sched_params;
|
||||||
|
RF_CmdHandle beacon_handle;
|
||||||
|
RF_EventMask beacon_events;
|
||||||
|
rf_result_t rf_result;
|
||||||
|
|
||||||
|
/* If no channels are mapped, then early return OK */
|
||||||
|
if((bm_channel & BLE_ADV_CHANNEL_ALL) == 0) {
|
||||||
|
return RF_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
initial_adv = init_ble_adv_array(ble_cmd_adv_nc_array, bm_channel);
|
||||||
|
|
||||||
|
if(initial_adv == NULL) {
|
||||||
|
LOG_ERR("Initializing BLE Advertismenet chain failed\n");
|
||||||
|
return RF_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
RF_ScheduleCmdParams_init(&sched_params);
|
||||||
sched_params.priority = RF_PriorityNormal;
|
sched_params.priority = RF_PriorityNormal;
|
||||||
sched_params.endTime = 0;
|
sched_params.endTime = 0;
|
||||||
sched_params.allowDelay = RF_AllowDelayAny;
|
sched_params.allowDelay = RF_AllowDelayAny;
|
||||||
|
|
||||||
CMD_STATUS(ble_cmd_beacon) = PENDING;
|
/*
|
||||||
|
* The most efficient way to schedule the command is as follows:
|
||||||
RF_CmdHandle beacon_handle = RF_scheduleCmd(
|
* 1. Schedule the BLE advertisement chain
|
||||||
&rf_ble,
|
* 2. Reschedule the RX command IF it was running.
|
||||||
(RF_Op *)&ble_cmd_beacon,
|
* 3. Pend on the BLE avertisement chain
|
||||||
&sched_params,
|
*/
|
||||||
cb,
|
beacon_handle = RF_scheduleCmd(
|
||||||
bm_event);
|
&rf_ble,
|
||||||
|
initial_adv,
|
||||||
|
&sched_params,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
if(!CMD_HANDLE_OK(beacon_handle)) {
|
if(!CMD_HANDLE_OK(beacon_handle)) {
|
||||||
LOG_ERR("Unable to schedule BLE Beacon command, handle=%d status=0x%04x\n",
|
LOG_ERR("Unable to schedule BLE Beacon command, handle=%d status=0x%04x\n",
|
||||||
beacon_handle, CMD_STATUS(ble_cmd_beacon));
|
beacon_handle, CMD_STATUS(ble_cmd_adv_nc));
|
||||||
|
|
||||||
return RF_RESULT_ERROR;
|
return RF_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint_fast8_t rx_key = cmd_rx_disable();
|
/* Note that this only reschedules RX if it is running */
|
||||||
|
rf_result = cmd_rx_restore(cmd_rx_disable());
|
||||||
|
|
||||||
/* Wait until Beacon operation finishes */
|
/* Wait until Beacon operation finishes */
|
||||||
RF_EventMask beacon_events = RF_pendCmd(&rf_ble, beacon_handle, 0);
|
beacon_events = RF_pendCmd(&rf_ble, beacon_handle, 0);
|
||||||
if(!EVENTS_CMD_DONE(beacon_events)) {
|
|
||||||
LOG_ERR("Pending on scheduled BLE Beacon command generated error, events=0x%08llx status=0x%04x\n",
|
if(rf_result != RF_RESULT_OK) {
|
||||||
beacon_events, CMD_STATUS(ble_cmd_beacon));
|
LOG_ERR("Rescheduling CMD_RX failed when BLE advertising\n");
|
||||||
|
|
||||||
|
return RF_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!EVENTS_CMD_DONE(beacon_events)) {
|
||||||
|
LOG_ERR("Pending on scheduled BLE Beacon command generated error, events=0x%08llx status=0x%04x\n",
|
||||||
|
beacon_events, CMD_STATUS(ble_cmd_adv_nc));
|
||||||
|
|
||||||
cmd_rx_restore(rx_key);
|
|
||||||
return RF_RESULT_ERROR;
|
return RF_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_rx_restore(rx_key);
|
|
||||||
return RF_RESULT_OK;
|
return RF_RESULT_OK;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -58,6 +58,16 @@ typedef enum {
|
||||||
RF_RESULT_ERROR,
|
RF_RESULT_ERROR,
|
||||||
} rf_result_t;
|
} rf_result_t;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
typedef enum {
|
||||||
|
BLE_ADV_CHANNEL_37 = (1 << 0),
|
||||||
|
BLE_ADV_CHANNEL_38 = (1 << 1),
|
||||||
|
BLE_ADV_CHANNEL_39 = (1 << 2),
|
||||||
|
|
||||||
|
BLE_ADV_CHANNEL_ALL = (BLE_ADV_CHANNEL_37 |
|
||||||
|
BLE_ADV_CHANNEL_38 |
|
||||||
|
BLE_ADV_CHANNEL_39),
|
||||||
|
} ble_adv_channel_t;
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \name Common RF scheduler functionality.
|
* \name Common RF scheduler functionality.
|
||||||
*
|
*
|
||||||
|
@ -91,7 +101,7 @@ rf_result_t netstack_stop_rx(void);
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
RF_Handle ble_open(RF_Params *params);
|
RF_Handle ble_open(RF_Params *params);
|
||||||
rf_result_t ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event);
|
rf_result_t ble_sched_beacons(uint8_t bm_adv_channel);
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* RF_SCHED_H_ */
|
#endif /* RF_SCHED_H_ */
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
#define ble_mode rf_ble_mode
|
#define ble_mode rf_ble_mode
|
||||||
#define ble_cmd_radio_setup rf_ble_cmd_radio_setup
|
#define ble_cmd_radio_setup rf_ble_cmd_radio_setup
|
||||||
#define ble_adv_par rf_ble_adv_par
|
#define ble_adv_par rf_ble_adv_par
|
||||||
#define ble_cmd_beacon rf_ble_cmd_ble_adv_nc
|
#define ble_cmd_adv_nc rf_ble_cmd_ble_adv_nc
|
||||||
|
|
||||||
/* CC13x2/CC26x2 devices */
|
/* CC13x2/CC26x2 devices */
|
||||||
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
#define ble_mode rf_ble_mode
|
#define ble_mode rf_ble_mode
|
||||||
#define ble_cmd_radio_setup rf_ble_cmd_radio_setup
|
#define ble_cmd_radio_setup rf_ble_cmd_radio_setup
|
||||||
#define ble_adv_par rf_ble_adv_par
|
#define ble_adv_par rf_ble_adv_par
|
||||||
#define ble_cmd_beacon rf_ble_cmd_ble_adv_nc
|
#define ble_cmd_adv_nc rf_ble_cmd_ble_adv_nc
|
||||||
|
|
||||||
#endif /* DeviceFamily_PARENT */
|
#endif /* DeviceFamily_PARENT */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue