Add D13 definition
Dependents: Program3_BLEHeartRate Program3_BLEHeartRate
Fork of X_NUCLEO_IDB0XA1 by
Diff: x-nucleo-idb0xa1/BlueNRGGap.h
- Revision:
- 229:9981f62cdb1a
- Parent:
- 228:25368f053411
- Child:
- 230:6eb53072d82b
--- a/x-nucleo-idb0xa1/BlueNRGGap.h Tue Apr 26 14:44:54 2016 +0200 +++ b/x-nucleo-idb0xa1/BlueNRGGap.h Mon May 16 17:22:03 2016 +0200 @@ -46,8 +46,8 @@ #define BDADDR_SIZE 6 #define BLUENRG_GAP_ADV_INTERVAL_MIN (0x0020) -#define BLUENRG_GAP_ADV_INTERVAL_MAX (0x00A0) -#define BLUENRG_GAP_ADV_NONCON_INTERVAL_MIN (0x4000) +#define BLUENRG_GAP_ADV_INTERVAL_MAX (0x4000) +#define BLUENRG_GAP_ADV_NONCON_INTERVAL_MIN (0x00A0) // Scanning and Connection Params used by Central for creating connection #define GAP_OBSERVATION_PROC (0x80) @@ -59,8 +59,9 @@ #define CONN_L(x) ((int)((x)/0.625f)) #define CONN_P1 ((int)(_advParams.getInterval()+5)/1.25f)//(0x4C)//(0x6C) #define CONN_P2 ((int)(_advParams.getInterval()+5)/1.25f)//(0x4C)//(0x6C) -#define CONN_L1 (0x000C) -#define CONN_L2 (0x000C) +#define CONN_L1 (0x0008) +#define CONN_L2 (0x0008) +#define GUARD_INT 5 //msec #define LOCAL_NAME_MAX_SIZE 9 //8 + 1(AD_DATA_TYPE) #define UUID_BUFFER_SIZE 17 //Either 8*2(16-bit UUIDs) or 4*4(32-bit UUIDs) or 1*16(128-bit UUIDs) +1(AD_DATA_TYPE) @@ -80,22 +81,13 @@ return m_instance; } - // <<<ANDREA>>> - /* - enum AdvType_t { - ADV_IND = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED,//Gap::ADV_IND, - ADV_DIRECT_IND = GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED,//Gap::ADV_DIRECT_IND, - ADV_SCAN_IND = GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED,//Gap::ADV_SCAN_IND, - ADV_NONCONN_IND = GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED//Gap::ADV_NONCONN_IND - }; - */ enum Reason_t { DEVICE_FOUND, DISCOVERY_COMPLETE }; /* Functions that must be implemented from Gap */ - /*virtual ble_error_t setAddress(addr_type_t type, const Address_t address);*/ + virtual ble_error_t setAddress(addr_type_t type, const Address_t address); virtual ble_error_t getAddress(addr_type_t *typeP, Address_t address); virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &); virtual ble_error_t startAdvertising(const GapAdvertisingParams &); @@ -114,19 +106,25 @@ virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance); virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP); - + + virtual ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode); + virtual ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode); + virtual AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const; + virtual ScanningPolicyMode_t getScanningPolicyMode(void) const; + virtual ble_error_t setTxPower(int8_t txPower); virtual void getPermittedTxPowerValues(const int8_t **, size_t *); - // <<<ANDREA>>> + virtual ble_error_t connect(const Address_t peerAddr, Gap::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams); - + + virtual ble_error_t reset(void); void Discovery_CB(Reason_t reason, uint8_t adv_type, - uint8_t *addr_type, + uint8_t addr_type, uint8_t *addr, uint8_t *data_length, uint8_t *data, @@ -156,6 +154,7 @@ uint16_t m_connectionHandle; AddressType_t addr_type; Address_t _peerAddr; + AddressType_t _peerAddrType; uint8_t bdaddr[BDADDR_SIZE]; bool _scanning; bool _connecting; @@ -174,9 +173,29 @@ Timeout advTimeout; bool AdvToFlag; + static uint16_t SCAN_DURATION_UNITS_TO_MSEC(uint16_t duration) { + return (duration * 625) / 1000; + } + + uint16_t scanInterval; + uint16_t scanWindow; + uint16_t conn_min_interval; + uint16_t conn_max_interval; + void setConnectionParameters(void); + + Gap::AdvertisingPolicyMode_t advertisingPolicyMode; + Gap::ScanningPolicyMode_t scanningPolicyMode; + + Whitelist_t whitelistAddresses; + BlueNRGGap() { m_connectionHandle = BLE_CONN_HANDLE_INVALID; addr_type = BLEProtocol::AddressType::RANDOM_STATIC; + + /* Set the whitelist policy filter modes to IGNORE_WHITELIST */ + advertisingPolicyMode = Gap::ADV_POLICY_IGNORE_WHITELIST; + scanningPolicyMode = Gap::SCAN_POLICY_FILTER_ALL_ADV;//Gap::SCAN_POLICY_IGNORE_WHITELIST; + isSetAddress = false; memset(deviceAppearance, 0, sizeof(deviceAppearance)); }