Minor temporary patch to allow DFU packet callback
Fork of BLE_API by
GapAdvertisingParams.cpp@19:a6f33421746c, 2013-12-18 (annotated)
- Committer:
- ktownsend
- Date:
- Wed Dec 18 20:11:45 2013 +0000
- Revision:
- 19:a6f33421746c
- Parent:
- 18:86fe1e247a54
- Child:
- 27:4a83843f04b0
A few more doxygen improvements
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ktownsend | 2:ffc5216bd2cc | 1 | #include <stdio.h> |
ktownsend | 2:ffc5216bd2cc | 2 | #include <string.h> |
ktownsend | 2:ffc5216bd2cc | 3 | |
ktownsend | 4:50a31ff5f974 | 4 | #include "blecommon.h" |
ktownsend | 2:ffc5216bd2cc | 5 | #include "GapAdvertisingParams.h" |
ktownsend | 2:ffc5216bd2cc | 6 | |
ktownsend | 2:ffc5216bd2cc | 7 | /**************************************************************************/ |
ktownsend | 2:ffc5216bd2cc | 8 | /*! |
ktownsend | 18:86fe1e247a54 | 9 | \brief |
ktownsend | 18:86fe1e247a54 | 10 | Instantiates a new GapAdvertisingParams instance |
ktownsend | 4:50a31ff5f974 | 11 | |
ktownsend | 18:86fe1e247a54 | 12 | \param[in] advType |
ktownsend | 6:425638944835 | 13 | The GAP advertising mode to use for this device. Valid |
ktownsend | 19:a6f33421746c | 14 | values are defined in AdvertisingType: |
ktownsend | 2:ffc5216bd2cc | 15 | |
ktownsend | 18:86fe1e247a54 | 16 | \par ADV_NON_CONNECTABLE_UNDIRECTED |
ktownsend | 18:86fe1e247a54 | 17 | All connections to the peripheral device will be refused. |
ktownsend | 4:50a31ff5f974 | 18 | |
ktownsend | 18:86fe1e247a54 | 19 | \par ADV_CONNECTABLE_DIRECTED |
ktownsend | 18:86fe1e247a54 | 20 | Only connections from a pre-defined central device will be |
ktownsend | 18:86fe1e247a54 | 21 | accepted. |
ktownsend | 4:50a31ff5f974 | 22 | |
ktownsend | 18:86fe1e247a54 | 23 | \par ADV_CONNECTABLE_UNDIRECTED |
ktownsend | 18:86fe1e247a54 | 24 | Any central device can connect to this peripheral. |
ktownsend | 6:425638944835 | 25 | |
ktownsend | 18:86fe1e247a54 | 26 | \par ADV_SCANNABLE_UNDIRECTED |
ktownsend | 18:86fe1e247a54 | 27 | Any central device can connect to this peripheral, and |
ktownsend | 18:86fe1e247a54 | 28 | the secondary Scan Response payload will be included or |
ktownsend | 18:86fe1e247a54 | 29 | available to central devices. |
ktownsend | 18:86fe1e247a54 | 30 | |
ktownsend | 19:a6f33421746c | 31 | \par |
ktownsend | 18:86fe1e247a54 | 32 | See Bluetooth Core Specification 4.0 (Vol. 3), Part C, |
ktownsend | 18:86fe1e247a54 | 33 | Section 9.3 and Core Specification 4.0 (Vol. 6), Part B, |
ktownsend | 18:86fe1e247a54 | 34 | Section 2.3.1 for further information on GAP connection |
ktownsend | 18:86fe1e247a54 | 35 | modes |
ktownsend | 4:50a31ff5f974 | 36 | |
ktownsend | 18:86fe1e247a54 | 37 | \param[in] interval |
ktownsend | 14:6ea5d1012a64 | 38 | Advertising interval between 0x0020 and 0x4000 in 0.625ms |
ktownsend | 14:6ea5d1012a64 | 39 | units (20ms to 10.24s). If using non-connectable mode |
ktownsend | 18:86fe1e247a54 | 40 | (ADV_NON_CONNECTABLE_UNDIRECTED) this min value is |
ktownsend | 14:6ea5d1012a64 | 41 | 0x00A0 (100ms). |
ktownsend | 4:50a31ff5f974 | 42 | |
ktownsend | 18:86fe1e247a54 | 43 | \par |
ktownsend | 4:50a31ff5f974 | 44 | Increasing this value will allow central devices to detect |
ktownsend | 4:50a31ff5f974 | 45 | your peripheral faster at the expense of more power being |
ktownsend | 4:50a31ff5f974 | 46 | used by the radio due to the higher data transmit rate. |
ktownsend | 4:50a31ff5f974 | 47 | |
ktownsend | 19:a6f33421746c | 48 | \par |
ktownsend | 18:86fe1e247a54 | 49 | This field must be set to 0 if connectionMode is equal |
ktownsend | 18:86fe1e247a54 | 50 | to ADV_CONNECTABLE_DIRECTED |
ktownsend | 14:6ea5d1012a64 | 51 | |
ktownsend | 19:a6f33421746c | 52 | \par |
ktownsend | 18:86fe1e247a54 | 53 | See Bluetooth Core Specification, Vol 3., Part C, |
ktownsend | 19:a6f33421746c | 54 | Appendix A for suggested advertising intervals. |
ktownsend | 14:6ea5d1012a64 | 55 | |
ktownsend | 18:86fe1e247a54 | 56 | \param[in] timeout |
ktownsend | 4:50a31ff5f974 | 57 | Advertising timeout between 0x1 and 0x3FFF (1 and 16383) |
ktownsend | 4:50a31ff5f974 | 58 | in seconds. Enter 0 to disable the advertising timeout. |
ktownsend | 4:50a31ff5f974 | 59 | |
ktownsend | 18:86fe1e247a54 | 60 | \par EXAMPLE |
ktownsend | 2:ffc5216bd2cc | 61 | |
ktownsend | 18:86fe1e247a54 | 62 | \code |
ktownsend | 2:ffc5216bd2cc | 63 | |
ktownsend | 18:86fe1e247a54 | 64 | \endcode |
ktownsend | 2:ffc5216bd2cc | 65 | */ |
ktownsend | 2:ffc5216bd2cc | 66 | /**************************************************************************/ |
ktownsend | 6:425638944835 | 67 | GapAdvertisingParams::GapAdvertisingParams(AdvertisingType advType, uint16_t interval, uint16_t timeout) |
ktownsend | 2:ffc5216bd2cc | 68 | { |
ktownsend | 6:425638944835 | 69 | _advType = advType; |
ktownsend | 2:ffc5216bd2cc | 70 | _interval = interval; |
ktownsend | 2:ffc5216bd2cc | 71 | _timeout = timeout; |
ktownsend | 4:50a31ff5f974 | 72 | |
ktownsend | 4:50a31ff5f974 | 73 | /* Interval checks */ |
ktownsend | 6:425638944835 | 74 | if (_advType == ADV_CONNECTABLE_DIRECTED) |
ktownsend | 4:50a31ff5f974 | 75 | { |
ktownsend | 4:50a31ff5f974 | 76 | /* Interval must be 0 in directed connectable mode */ |
ktownsend | 4:50a31ff5f974 | 77 | _interval = 0; |
ktownsend | 4:50a31ff5f974 | 78 | } |
ktownsend | 14:6ea5d1012a64 | 79 | else if (_advType == ADV_NON_CONNECTABLE_UNDIRECTED) |
ktownsend | 14:6ea5d1012a64 | 80 | { |
ktownsend | 14:6ea5d1012a64 | 81 | /* Min interval is slightly larger than in other modes */ |
ktownsend | 14:6ea5d1012a64 | 82 | if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) |
ktownsend | 14:6ea5d1012a64 | 83 | { |
ktownsend | 14:6ea5d1012a64 | 84 | _interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON; |
ktownsend | 14:6ea5d1012a64 | 85 | } |
ktownsend | 14:6ea5d1012a64 | 86 | if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) |
ktownsend | 14:6ea5d1012a64 | 87 | { |
ktownsend | 14:6ea5d1012a64 | 88 | _interval = GAP_ADV_PARAMS_INTERVAL_MAX; |
ktownsend | 14:6ea5d1012a64 | 89 | } |
ktownsend | 14:6ea5d1012a64 | 90 | } |
ktownsend | 4:50a31ff5f974 | 91 | else |
ktownsend | 4:50a31ff5f974 | 92 | { |
ktownsend | 4:50a31ff5f974 | 93 | /* Stay within interval limits */ |
ktownsend | 4:50a31ff5f974 | 94 | if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN) |
ktownsend | 4:50a31ff5f974 | 95 | { |
ktownsend | 4:50a31ff5f974 | 96 | _interval = GAP_ADV_PARAMS_INTERVAL_MIN; |
ktownsend | 4:50a31ff5f974 | 97 | } |
ktownsend | 4:50a31ff5f974 | 98 | if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) |
ktownsend | 4:50a31ff5f974 | 99 | { |
ktownsend | 4:50a31ff5f974 | 100 | _interval = GAP_ADV_PARAMS_INTERVAL_MAX; |
ktownsend | 4:50a31ff5f974 | 101 | } |
ktownsend | 4:50a31ff5f974 | 102 | } |
ktownsend | 4:50a31ff5f974 | 103 | |
ktownsend | 4:50a31ff5f974 | 104 | /* Timeout checks */ |
ktownsend | 4:50a31ff5f974 | 105 | if (timeout) |
ktownsend | 4:50a31ff5f974 | 106 | { |
ktownsend | 4:50a31ff5f974 | 107 | /* Stay within timeout limits */ |
ktownsend | 4:50a31ff5f974 | 108 | if (_timeout > GAP_ADV_PARAMS_TIMEOUT_MAX) |
ktownsend | 4:50a31ff5f974 | 109 | { |
ktownsend | 4:50a31ff5f974 | 110 | _timeout = GAP_ADV_PARAMS_TIMEOUT_MAX; |
ktownsend | 4:50a31ff5f974 | 111 | } |
ktownsend | 4:50a31ff5f974 | 112 | } |
ktownsend | 2:ffc5216bd2cc | 113 | } |
ktownsend | 2:ffc5216bd2cc | 114 | |
ktownsend | 2:ffc5216bd2cc | 115 | /**************************************************************************/ |
ktownsend | 2:ffc5216bd2cc | 116 | /*! |
ktownsend | 2:ffc5216bd2cc | 117 | Destructor |
ktownsend | 2:ffc5216bd2cc | 118 | */ |
ktownsend | 2:ffc5216bd2cc | 119 | /**************************************************************************/ |
ktownsend | 2:ffc5216bd2cc | 120 | GapAdvertisingParams::~GapAdvertisingParams(void) |
ktownsend | 2:ffc5216bd2cc | 121 | { |
ktownsend | 2:ffc5216bd2cc | 122 | } |
ktownsend | 7:5e1f0d7f7c7d | 123 | |
ktownsend | 7:5e1f0d7f7c7d | 124 | /**************************************************************************/ |
ktownsend | 7:5e1f0d7f7c7d | 125 | /*! |
ktownsend | 18:86fe1e247a54 | 126 | \brief returns the current Advertising Type value |
ktownsend | 7:5e1f0d7f7c7d | 127 | */ |
ktownsend | 7:5e1f0d7f7c7d | 128 | /**************************************************************************/ |
ktownsend | 7:5e1f0d7f7c7d | 129 | GapAdvertisingParams::AdvertisingType GapAdvertisingParams::getAdvertisingType(void) |
ktownsend | 7:5e1f0d7f7c7d | 130 | { |
ktownsend | 7:5e1f0d7f7c7d | 131 | return _advType; |
ktownsend | 7:5e1f0d7f7c7d | 132 | } |
ktownsend | 9:124ae067ae27 | 133 | |
ktownsend | 9:124ae067ae27 | 134 | /**************************************************************************/ |
ktownsend | 9:124ae067ae27 | 135 | /*! |
ktownsend | 18:86fe1e247a54 | 136 | \brief returns the current Advertising Delay (in units of 0.625ms) |
ktownsend | 9:124ae067ae27 | 137 | */ |
ktownsend | 9:124ae067ae27 | 138 | /**************************************************************************/ |
ktownsend | 9:124ae067ae27 | 139 | uint16_t GapAdvertisingParams::getInterval(void) |
ktownsend | 9:124ae067ae27 | 140 | { |
ktownsend | 9:124ae067ae27 | 141 | return _interval; |
ktownsend | 9:124ae067ae27 | 142 | } |
ktownsend | 9:124ae067ae27 | 143 | |
ktownsend | 9:124ae067ae27 | 144 | /**************************************************************************/ |
ktownsend | 9:124ae067ae27 | 145 | /*! |
ktownsend | 18:86fe1e247a54 | 146 | \brief returns the current Advertising Timeout (in seconds) |
ktownsend | 9:124ae067ae27 | 147 | */ |
ktownsend | 9:124ae067ae27 | 148 | /**************************************************************************/ |
ktownsend | 9:124ae067ae27 | 149 | uint16_t GapAdvertisingParams::getTimeout(void) |
ktownsend | 9:124ae067ae27 | 150 | { |
ktownsend | 9:124ae067ae27 | 151 | return _timeout; |
ktownsend | 9:124ae067ae27 | 152 | } |