iso ble 连接参数限制

上面的设置符合IOS的蓝牙连接规范,改规范如下:

The connection parameter request may be rejected if it does not comply with all of these rules: 
Interval Max * (Slave Latency + 1) ≤ 2 seconds 
Interval Min ≥ 20 ms 
Interval Min + 20 ms ≤ Interval Max 
Slave Latency ≤ 4 
connSupervisionTimeout ≤ 6 seconds 
Interval Max*(Slave Latency+1) * 3 < connSupervisionTimeout

------------------------------------------------------------------------------------

Interval Max = 800*1.25ms = 1000ms  (√)

Interval Min = 80*1.25ms = 100ms  ()

Slave Latency  = 0   ()

connSupervisionTimeout  =1000*10ms =10s  ()

----------------------------------------------------------------------------------------------------------------------------simple_peripheral.c

// Advertising interval when device is discoverable (units of 625us, 160=100ms)    当设备被发现时的广告间隔
#define DEFAULT_ADVERTISING_INTERVAL          160

// General discoverable mode: advertise indefinitely                                      一般可发现模式:无限广告。

#define DEFAULT_DISCOVERABLE_MODE             GAP_ADTYPE_FLAGS_GENERAL

低功耗蓝牙的发现模式主要分为有限可发现模式普通可发现模式


// Minimum connection interval (units of 1.25ms, 80=100ms) for automatic parameter update request    最小连接间隔(1.25ms, 80=100ms)自动参数更新请求。
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL     80
// Maximum connection interval (units of 1.25ms, 800=1000ms) for automatic parameter update request  最大连接间隔(1.25ms, 80=100ms)自动参数更新请求。
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL     800
// Slave latency to use for automatic parameter update request                 //用于自动参数更新请求的从属延迟。
#define DEFAULT_DESIRED_SLAVE_LATENCY         0
// Supervision timeout value (units of 10ms, 1000=10s) for automatic parameter update request   //监管超时值(10ms单位,1000=10s)自动参数更新请求。
#define DEFAULT_DESIRED_CONN_TIMEOUT          1000

// After the connection is formed, the peripheral waits until the central device asks for its preferred connection parameters   //连接形成后,外围设备等待中央设备请求其首选连接参数。

#define DEFAULT_ENABLE_UPDATE_REQUEST         GAPROLE_LINK_PARAM_UPDATE_WAIT_REMOTE_PARAMS
// Connection Pause Peripheral time value (in seconds)    //连接暂停时间值(以秒为单位)
#define DEFAULT_CONN_PAUSE_PERIPHERAL         6
// How often to perform periodic event (in msec)     //多久进行一次定期活动(在msec)
#define SBP_PERIODIC_EVT_PERIOD               30

---------------------------------------------------------------------------------------------------------------------------simple_peripheral.c

    uint8_t enableUpdateRequest = DEFAULT_ENABLE_UPDATE_REQUEST;
    uint16_t desiredMinInterval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
    uint16_t desiredMaxInterval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
    uint16_t desiredSlaveLatency = DEFAULT_DESIRED_SLAVE_LATENCY;
    uint16_t desiredConnTimeout = DEFAULT_DESIRED_CONN_TIMEOUT;

    // Set the Peripheral GAPRole Parameters
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initialAdvertEnable);
    GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),&advertOffTime);
    GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),  scanRspData);
    GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
    GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE, sizeof(uint8_t), &enableUpdateRequest);
    GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t), &desiredMinInterval);
    GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t), &desiredMaxInterval);
    GAPRole_SetParameter(GAPROLE_SLAVE_LATENCY, sizeof(uint16_t), &desiredSlaveLatency);
    GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t), &desiredConnTimeout);


  // Set GAP Parameters to set the advertising interval
  // For more information, see the GAP section of the User's Guide:
  // http://software-dl.ti.com/lprf/sdg-latest/html
  {
    // Use the same interval for general and limited advertising.
    // Note that only general advertising will occur based on the above configuration
    uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
    GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MIN, advInt);
    GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MAX, advInt);
    GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, advInt);
    GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, advInt);
  }

---------------------------------------------------------------------------------------------------------------------------gap.h

/**
  * @brief Minimum time to remain advertising, when in general discoverable mode (ms)
  *
  * Setting this parameter to 0 turns off the timeout, thus allowing infinite advertising
  *
  * default: 0
  *
  * range: 0-65535
  */
#define TGAP_GEN_DISC_ADV_MIN          0


/**
  * @brief Time to remain advertising in limited discovery mode (sec)
  *
  * default: 180
  *
  * range: 1-65535
  */
#define TGAP_LIM_ADV_TIMEOUT           1


/**
  * @brief Time to perform scanning for general discovery (ms)
  *
  * default: 10240
  *
  * range: 1-65535
  */
#define TGAP_GEN_DISC_SCAN             2


/**
  * @brief Time to perform scanning for limited discovery (ms)
  *
  * default: 10240
  *
  * range: 1-65535
  */
#define TGAP_LIM_DISC_SCAN             3


/**
  * @brief Advertising timeout when performing connection establishment (ms)
  *
  * default: 10240
  *
  * range: 1-65535
  */
#define TGAP_CONN_EST_ADV_TIMEOUT      4


/**
  * @brief Timeout for link layer to wait to receive connection parameter
  * update response before giving up (ms)
  *
  * default: 30000
  *
  * range: 1-65535
  */
#define TGAP_CONN_PARAM_TIMEOUT        5


/**
  * @brief Minimum advertising interval in limited discovery mode (n × 0.625 ms)
  *
  * default: 160
  *
  * range: 32-16384
  */
#define TGAP_LIM_DISC_ADV_INT_MIN      6


/**
  * @brief Maximum advertising interval in limited discovery mode (n × 0.625 ms)
  *
  * default: 160
  *
  * range: 32-16384
  */
#define TGAP_LIM_DISC_ADV_INT_MAX      7


/**
  * @brief Minimum advertising interval in general discovery mode (n × 0.625 ms)
  *
  * default: 160
  *
  * range: 32-16384
  */
#define TGAP_GEN_DISC_ADV_INT_MIN      8


/**
  * @brief Maximum advertising interval in general discovery mode (n × 0.625 ms)
  *
  * default: 160
  *
  * range: 32-16384
  */
#define TGAP_GEN_DISC_ADV_INT_MAX      9


/**
  * @brief Minimum advertising interval, when in Connectable mode (n * 0.625 mSec)
  *
  * default: 2048
  *
  * range: 32-16384
  */
#define TGAP_CONN_ADV_INT_MIN         10


/**
  * @brief Maximum advertising interval, when in Connectable mode (n * 0.625 mSec)
  *
  * default: 2048
  *
  * range: 32-16384
  */
#define TGAP_CONN_ADV_INT_MAX         11


/**
  * @brief Scan interval used during connection establishment (n * 0.625 mSec)
  *
  * default: 480
  *
  * range: 4-16384
  */
#define TGAP_CONN_SCAN_INT            12


/**
  * @brief Scan window used during connection establishment (n * 0.625 mSec)
  *
  * default: 240
  *
  * range: 4-16384
  */
#define TGAP_CONN_SCAN_WIND           13


/**
  * @brief Scan interval used during connection establishment, high duty scan cycle scan parameters (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_CONN_HIGH_SCAN_INT       14


/**
  * @brief Scan window used during connection establishment, high duty scan cycle scan parameters (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_CONN_HIGH_SCAN_WIND      15


/**
  * @brief Scan interval used when in General Discovery proc (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_GEN_DISC_SCAN_INT        16


/**
  * @brief Scan window used when in General Discovery proc (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_GEN_DISC_SCAN_WIND       17


/**
  * @brief Scan interval used when in Limited Discovery proc (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_LIM_DISC_SCAN_INT        18


/**
  * @brief Scan window used when in Limited Discovery proc (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_LIM_DISC_SCAN_WIND       19


/// @cond NODOC
/**
  * @brief Advertising interval, when using Connection Establishment proc (n * 0.625 mSec)
  *
  * Obsolete - Do not use.
  */
#define TGAP_CONN_EST_ADV             20
/// @endcond // NODOC


/**
  * @brief Minimum connection interval for connection establishment (n * 1.25 mSec)
  *
  * default: 80
  *
  * range: 6-3200
  */
#define TGAP_CONN_EST_INT_MIN         21


/**
  * @brief Maximum connection interval for connection establishment (n * 1.25 mSec)
  *
  * default: 80
  *
  * range: 6-3200
  */
#define TGAP_CONN_EST_INT_MAX         22


/**
  * @brief Scan interval used during during connection establishment (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_CONN_EST_SCAN_INT        23


/**
  * @brief Scan window used during during connection establishment (n * 0.625 mSec)
  *
  * default: 16
  *
  * range: 4-16384
  */
#define TGAP_CONN_EST_SCAN_WIND       24


/**
  * @brief Connection supervision timeout for connection establishment (n * 10 mSec)
  *
  * default: 2000
  *
  * range: 10-3200
  */
#define TGAP_CONN_EST_SUPERV_TIMEOUT  25


/**
  * @brief Slave latency for connection establishment (in number of connection events)
  *
  * default: 0
  *
  * range: 0-499
  */
#define TGAP_CONN_EST_LATENCY         26


/**
  * @brief Local informational parameter about min len of connection needed, when using Connection Establishment proc (n * 0.625 mSec)
  *
  * default: 0
  *
  * range: < @ref TGAP_CONN_EST_MAX_CE_LEN
  */
#define TGAP_CONN_EST_MIN_CE_LEN      27


/**
  * @brief Local informational parameter about max len of connection needed, when using Connection Establishment proc (n * 0.625 mSec)
  *
  * default: 0
  *
  * range: > @ref TGAP_CONN_EST_MIN_CE_LEN
  */
#define TGAP_CONN_EST_MAX_CE_LEN      28


/**
  * @brief Minimum Time Interval between private (resolvable) address changes (minutes)
  *
  * default: 15
  *
  * range: 1-65535
  */
#define TGAP_PRIVATE_ADDR_INT         29


/**
  * @brief Central idle timer (seconds)
  *
  * default: 1
  *
  * range: 1-65535
  */
#define TGAP_CONN_PAUSE_CENTRAL       30


/**
  * @brief Minimum time upon connection establishment before the peripheral starts a connection update procedure (seconds)
  *
  * default: 5
  *
  * range: 1-65535
  */
#define TGAP_CONN_PAUSE_PERIPHERAL    31


/**
  * @brief Time to wait for security manager response before returning bleTimeout (ms)
  *
  * default: 30000
  *
  * range: 1-65535
  */
#define TGAP_SM_TIMEOUT               32


/**
  * @brief SM Minimum Key Length supported
  *
  * default: 7
  *
  * range: 1-65535
  */
#define TGAP_SM_MIN_KEY_LEN           33


/**
  * @brief SM Maximum Key Length supported
  *
  * default: 16
  *
  * range: 1-65535
  */
#define TGAP_SM_MAX_KEY_LEN           34


/**
  * @brief Filter duplicate advertising reports
  *
  * default: TRUE
  *
  * range: 0-1
  */
#define TGAP_FILTER_ADV_REPORTS       35


/**
  * @brief Minimum RSSI required for scan responses to be reported to the app (dBm)
  *
  * default: -127
  *
  * range: -965535 - 0
  */
#define TGAP_SCAN_RSP_RSSI_MIN        36


/**
  * @brief Whether or not to reject Connection Parameter Update Request received on Central device
  *
  * default: FALSE
  *
  * range: 0-1
  */
#define TGAP_REJECT_CONN_PARAMS       37

你可能感兴趣的:(CC2541-BLE-4.0)