mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(bt): Add a parameter in the two least significant bits of Class of Device
This commit is contained in:
parent
592e743dad
commit
20990096b2
@ -180,6 +180,7 @@ esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
case ESP_BT_SET_COD_RESERVED_2:
|
||||||
case ESP_BT_SET_COD_MAJOR_MINOR:
|
case ESP_BT_SET_COD_MAJOR_MINOR:
|
||||||
case ESP_BT_SET_COD_SERVICE_CLASS:
|
case ESP_BT_SET_COD_SERVICE_CLASS:
|
||||||
case ESP_BT_CLR_COD_SERVICE_CLASS:
|
case ESP_BT_CLR_COD_SERVICE_CLASS:
|
||||||
|
@ -33,8 +33,9 @@ typedef enum {
|
|||||||
ESP_BT_SET_COD_MAJOR_MINOR = 0x01, /*!< overwrite major, minor class */
|
ESP_BT_SET_COD_MAJOR_MINOR = 0x01, /*!< overwrite major, minor class */
|
||||||
ESP_BT_SET_COD_SERVICE_CLASS = 0x02, /*!< set the bits in the input, the current bit will remain */
|
ESP_BT_SET_COD_SERVICE_CLASS = 0x02, /*!< set the bits in the input, the current bit will remain */
|
||||||
ESP_BT_CLR_COD_SERVICE_CLASS = 0x04, /*!< clear the bits in the input, others will remain */
|
ESP_BT_CLR_COD_SERVICE_CLASS = 0x04, /*!< clear the bits in the input, others will remain */
|
||||||
ESP_BT_SET_COD_ALL = 0x08, /*!< overwrite major, minor, set the bits in service class */
|
ESP_BT_SET_COD_ALL = 0x08, /*!< overwrite major, minor, set the bits in service class, reserved_2 remain unchanged */
|
||||||
ESP_BT_INIT_COD = 0x0a, /*!< overwrite major, minor, and service class */
|
ESP_BT_INIT_COD = 0x0a, /*!< overwrite major, minor, and service class, reserved_2 remain unchanged */
|
||||||
|
ESP_BT_SET_COD_RESERVED_2 = 0x10, /*!< overwrite the two least significant bits reserved_2 whose default value is 0b00; other values of reserved_2 are invalid according to Bluetooth Core Specification 5.4 */
|
||||||
} esp_bt_cod_mode_t;
|
} esp_bt_cod_mode_t;
|
||||||
|
|
||||||
#define ESP_BT_GAP_AFH_CHANNELS_LEN 10
|
#define ESP_BT_GAP_AFH_CHANNELS_LEN 10
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#define BTA_UTL_CLR_COD_SERVICE_CLASS 0x04
|
#define BTA_UTL_CLR_COD_SERVICE_CLASS 0x04
|
||||||
#define BTA_UTL_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */
|
#define BTA_UTL_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */
|
||||||
#define BTA_UTL_INIT_COD 0x0a
|
#define BTA_UTL_INIT_COD 0x0a
|
||||||
|
#define BTA_UTL_SET_COD_RESERVED_2 0x10 /* overwrite the two least significant bits reserved_2 */
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
** Type Definitions
|
** Type Definitions
|
||||||
@ -43,6 +44,7 @@
|
|||||||
|
|
||||||
/** for utl_set_device_class() **/
|
/** for utl_set_device_class() **/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
UINT8 reserved_2;
|
||||||
UINT8 minor;
|
UINT8 minor;
|
||||||
UINT8 major;
|
UINT8 major;
|
||||||
UINT16 service;
|
UINT16 service;
|
||||||
@ -125,11 +127,12 @@ extern void utl_freebuf(void **p);
|
|||||||
** p_cod - Pointer to the device class to set to
|
** p_cod - Pointer to the device class to set to
|
||||||
**
|
**
|
||||||
** cmd - the fields of the device class to update.
|
** cmd - the fields of the device class to update.
|
||||||
|
** BTA_UTL_SET_COD_RESERVED_2 - overwrite the two least significant bits reserved_2
|
||||||
** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class
|
** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class
|
||||||
** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input
|
** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input
|
||||||
** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input
|
** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input
|
||||||
** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class
|
** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class, reserved_2 remain unchanged
|
||||||
** BTA_UTL_INIT_COD - overwrite major, minor, and service class
|
** BTA_UTL_INIT_COD - overwrite major, minor, and service class, reserved_2 remain unchanged
|
||||||
**
|
**
|
||||||
** Returns TRUE if successful, Otherwise FALSE
|
** Returns TRUE if successful, Otherwise FALSE
|
||||||
**
|
**
|
||||||
|
@ -170,11 +170,12 @@ void utl_freebuf(void **p)
|
|||||||
** p_cod - Pointer to the device class to set to
|
** p_cod - Pointer to the device class to set to
|
||||||
**
|
**
|
||||||
** cmd - the fields of the device class to update.
|
** cmd - the fields of the device class to update.
|
||||||
|
** BTA_UTL_SET_COD_RESERVED_2 - overwrite the two least significant bits reserved_2
|
||||||
** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class
|
** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class
|
||||||
** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input
|
** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input
|
||||||
** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input
|
** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input
|
||||||
** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class
|
** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class, reserved_2 remain unchanged
|
||||||
** BTA_UTL_INIT_COD - overwrite major, minor, and service class
|
** BTA_UTL_INIT_COD - overwrite major, minor, and service class, reserved_2 remain unchanged
|
||||||
**
|
**
|
||||||
** Returns TRUE if successful, Otherwise FALSE
|
** Returns TRUE if successful, Otherwise FALSE
|
||||||
**
|
**
|
||||||
@ -183,15 +184,19 @@ BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd)
|
|||||||
{
|
{
|
||||||
UINT8 *dev;
|
UINT8 *dev;
|
||||||
UINT16 service;
|
UINT16 service;
|
||||||
UINT8 minor, major;
|
UINT8 minor, major, reserved_2;
|
||||||
DEV_CLASS dev_class;
|
DEV_CLASS dev_class;
|
||||||
|
|
||||||
dev = BTM_ReadDeviceClass();
|
dev = BTM_ReadDeviceClass();
|
||||||
BTM_COD_SERVICE_CLASS( service, dev );
|
BTM_COD_SERVICE_CLASS( service, dev );
|
||||||
BTM_COD_MINOR_CLASS(minor, dev );
|
BTM_COD_MINOR_CLASS(minor, dev );
|
||||||
BTM_COD_MAJOR_CLASS(major, dev );
|
BTM_COD_MAJOR_CLASS(major, dev );
|
||||||
|
BTM_COD_RESERVED_2(reserved_2, dev);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
case BTA_UTL_SET_COD_RESERVED_2:
|
||||||
|
reserved_2 = p_cod->reserved_2 & BTM_COD_RESERVED_2_MASK;
|
||||||
|
break;
|
||||||
case BTA_UTL_SET_COD_MAJOR_MINOR:
|
case BTA_UTL_SET_COD_MAJOR_MINOR:
|
||||||
minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK;
|
minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK;
|
||||||
major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK;
|
major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK;
|
||||||
@ -226,7 +231,7 @@ BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert the fields into the device class type */
|
/* convert the fields into the device class type */
|
||||||
FIELDS_TO_COD(dev_class, minor, major, service);
|
FIELDS_TO_COD(dev_class, reserved_2, minor, major, service);
|
||||||
|
|
||||||
if (BTM_SetDeviceClass(dev_class) == BTM_SUCCESS) {
|
if (BTM_SetDeviceClass(dev_class) == BTM_SUCCESS) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -252,16 +257,18 @@ BOOLEAN utl_get_device_class(tBTA_UTL_COD *p_cod)
|
|||||||
{
|
{
|
||||||
UINT8 *dev;
|
UINT8 *dev;
|
||||||
UINT16 service;
|
UINT16 service;
|
||||||
UINT8 minor, major;
|
UINT8 minor, major, reserved_2;
|
||||||
|
|
||||||
dev = BTM_ReadDeviceClass();
|
dev = BTM_ReadDeviceClass();
|
||||||
BTM_COD_SERVICE_CLASS( service, dev );
|
BTM_COD_SERVICE_CLASS( service, dev );
|
||||||
BTM_COD_MINOR_CLASS(minor, dev );
|
BTM_COD_MINOR_CLASS(minor, dev );
|
||||||
BTM_COD_MAJOR_CLASS(major, dev );
|
BTM_COD_MAJOR_CLASS(major, dev );
|
||||||
|
BTM_COD_RESERVED_2(reserved_2, dev );
|
||||||
|
|
||||||
p_cod->minor = minor;
|
p_cod->minor = minor;
|
||||||
p_cod->major = major;
|
p_cod->major = major;
|
||||||
p_cod->service = service;
|
p_cod->service = service;
|
||||||
|
p_cod->reserved_2 = reserved_2;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -585,8 +585,8 @@ static void btc_gap_bt_set_cod(btc_gap_bt_args_t *arg)
|
|||||||
{
|
{
|
||||||
tBTA_UTL_COD p_cod;
|
tBTA_UTL_COD p_cod;
|
||||||
esp_bt_cod_t *cod = &(arg->set_cod.cod);
|
esp_bt_cod_t *cod = &(arg->set_cod.cod);
|
||||||
|
p_cod.reserved_2 = cod->reserved_2;
|
||||||
p_cod.minor = cod->minor << 2;
|
p_cod.minor = cod->minor << 2;
|
||||||
p_cod.minor |= cod->reserved_2;
|
|
||||||
p_cod.major = cod->major;
|
p_cod.major = cod->major;
|
||||||
p_cod.service = cod->service << 5;
|
p_cod.service = cod->service << 5;
|
||||||
bool ret = utl_set_device_class(&p_cod, arg->set_cod.mode);
|
bool ret = utl_set_device_class(&p_cod, arg->set_cod.mode);
|
||||||
@ -603,8 +603,8 @@ esp_err_t btc_gap_bt_get_cod(esp_bt_cod_t *cod)
|
|||||||
BTC_TRACE_ERROR("%s get class of device failed!",__func__);
|
BTC_TRACE_ERROR("%s get class of device failed!",__func__);
|
||||||
return ESP_BT_STATUS_FAIL;
|
return ESP_BT_STATUS_FAIL;
|
||||||
}
|
}
|
||||||
|
cod->reserved_2 = p_cod.reserved_2;
|
||||||
cod->minor = p_cod.minor >> 2;
|
cod->minor = p_cod.minor >> 2;
|
||||||
cod->reserved_2 = p_cod.minor & 0x03;
|
|
||||||
cod->major = p_cod.major;
|
cod->major = p_cod.major;
|
||||||
cod->service = p_cod.service >> 5;
|
cod->service = p_cod.service >> 5;
|
||||||
return ESP_BT_STATUS_SUCCESS;
|
return ESP_BT_STATUS_SUCCESS;
|
||||||
|
@ -163,7 +163,7 @@ tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, UINT16 inter
|
|||||||
UINT8 scan_mode = 0;
|
UINT8 scan_mode = 0;
|
||||||
UINT16 service_class;
|
UINT16 service_class;
|
||||||
UINT8 *p_cod;
|
UINT8 *p_cod;
|
||||||
UINT8 major, minor;
|
UINT8 major, minor, reserved_2;
|
||||||
DEV_CLASS cod;
|
DEV_CLASS cod;
|
||||||
LAP temp_lap[2];
|
LAP temp_lap[2];
|
||||||
BOOLEAN is_limited;
|
BOOLEAN is_limited;
|
||||||
@ -255,13 +255,14 @@ tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, UINT16 inter
|
|||||||
if (is_limited ^ cod_limited) {
|
if (is_limited ^ cod_limited) {
|
||||||
BTM_COD_MINOR_CLASS(minor, p_cod );
|
BTM_COD_MINOR_CLASS(minor, p_cod );
|
||||||
BTM_COD_MAJOR_CLASS(major, p_cod );
|
BTM_COD_MAJOR_CLASS(major, p_cod );
|
||||||
|
BTM_COD_RESERVED_2(reserved_2, p_cod);
|
||||||
if (is_limited) {
|
if (is_limited) {
|
||||||
service_class |= BTM_COD_SERVICE_LMTD_DISCOVER;
|
service_class |= BTM_COD_SERVICE_LMTD_DISCOVER;
|
||||||
} else {
|
} else {
|
||||||
service_class &= ~BTM_COD_SERVICE_LMTD_DISCOVER;
|
service_class &= ~BTM_COD_SERVICE_LMTD_DISCOVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
FIELDS_TO_COD(cod, minor, major, service_class);
|
FIELDS_TO_COD(cod, reserved_2, minor, major, service_class);
|
||||||
(void) BTM_SetDeviceClass (cod);
|
(void) BTM_SetDeviceClass (cod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +516,7 @@ tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms, UINT16 max_d
|
|||||||
|
|
||||||
/* Before beginning the inquiry the current filter must be cleared, so initiate the command */
|
/* Before beginning the inquiry the current filter must be cleared, so initiate the command */
|
||||||
if ((status = btm_set_inq_event_filter (p_inqparms->filter_cond_type, &p_inqparms->filter_cond)) != BTM_CMD_STARTED) {
|
if ((status = btm_set_inq_event_filter (p_inqparms->filter_cond_type, &p_inqparms->filter_cond)) != BTM_CMD_STARTED) {
|
||||||
/* If set filter command is not succesful reset the state */
|
/* If set filter command is not successful reset the state */
|
||||||
p_inq->p_inq_results_cb = NULL;
|
p_inq->p_inq_results_cb = NULL;
|
||||||
p_inq->state = BTM_INQ_INACTIVE_STATE;
|
p_inq->state = BTM_INQ_INACTIVE_STATE;
|
||||||
|
|
||||||
@ -688,7 +689,7 @@ UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval)
|
|||||||
** Description This function returns a bit mask of the current inquiry state
|
** Description This function returns a bit mask of the current inquiry state
|
||||||
**
|
**
|
||||||
** Returns BTM_INQUIRY_INACTIVE if inactive (0)
|
** Returns BTM_INQUIRY_INACTIVE if inactive (0)
|
||||||
** BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
|
** BTM_LIMITED_INQUIRY_ACTIVE if a limited inquiry is active
|
||||||
** BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
|
** BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
|
||||||
** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
|
** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
|
||||||
**
|
**
|
||||||
@ -783,7 +784,7 @@ tBTM_STATUS BTM_CancelInquiry(void)
|
|||||||
** Description This function is called to start an inquiry.
|
** Description This function is called to start an inquiry.
|
||||||
**
|
**
|
||||||
** Parameters: p_inqparms - pointer to the inquiry information
|
** Parameters: p_inqparms - pointer to the inquiry information
|
||||||
** mode - GENERAL or LIMITED inquiry, BR/LE bit mask seperately
|
** mode - GENERAL or LIMITED inquiry, BR/LE bit mask separately
|
||||||
** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
|
** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
|
||||||
** max_resps - maximum amount of devices to search for before ending the inquiry
|
** max_resps - maximum amount of devices to search for before ending the inquiry
|
||||||
** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
|
** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
|
||||||
@ -1858,7 +1859,7 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode)
|
|||||||
#if BLE_INCLUDED == TRUE
|
#if BLE_INCLUDED == TRUE
|
||||||
/* new device response */
|
/* new device response */
|
||||||
&& ( p_i == NULL ||
|
&& ( p_i == NULL ||
|
||||||
/* exisiting device with BR/EDR info */
|
/* existing device with BR/EDR info */
|
||||||
(p_i && (p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BREDR) != 0)
|
(p_i && (p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BREDR) != 0)
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
|
@ -435,22 +435,22 @@ typedef void (tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK) (UINT8 status);
|
|||||||
#define BTM_COD_SERVICE_INFORMATION 0x8000
|
#define BTM_COD_SERVICE_INFORMATION 0x8000
|
||||||
|
|
||||||
/* class of device field macros */
|
/* class of device field macros */
|
||||||
#define BTM_COD_FORMAT_TYPE(u8, pd) {u8 = pd[2]&0x03;}
|
#define BTM_COD_RESERVED_2(u8, pd) {u8 = pd[2]&0x03;}
|
||||||
#define BTM_COD_MINOR_CLASS(u8, pd) {u8 = pd[2]&0xFC;}
|
#define BTM_COD_MINOR_CLASS(u8, pd) {u8 = pd[2]&0xFC;}
|
||||||
#define BTM_COD_MAJOR_CLASS(u8, pd) {u8 = pd[1]&0x1F;}
|
#define BTM_COD_MAJOR_CLASS(u8, pd) {u8 = pd[1]&0x1F;}
|
||||||
#define BTM_COD_SERVICE_CLASS(u16, pd) {u16 = pd[0]; u16<<=8; u16 += pd[1]&0xE0;}
|
#define BTM_COD_SERVICE_CLASS(u16, pd) {u16 = pd[0]; u16<<=8; u16 += pd[1]&0xE0;}
|
||||||
|
|
||||||
/* to set the fields (assumes that format type is always 0) */
|
/* to set the fields (assumes that format type is always 0) */
|
||||||
#define FIELDS_TO_COD(pd, mn, mj, sv) {pd[2] = mn; pd[1] = \
|
#define FIELDS_TO_COD(pd, rs, mn, mj, sv) {pd[2] = (mn & BTM_COD_MINOR_CLASS_MASK) + (rs & BTM_COD_RESERVED_2_MASK); \
|
||||||
mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \
|
pd[1] = mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \
|
||||||
pd[0] = (sv) >> 8;}
|
pd[0] = (sv) >> 8;}
|
||||||
|
|
||||||
/* the COD masks */
|
/* the COD masks */
|
||||||
#define BTM_COD_FORMAT_TYPE_MASK 0x03
|
#define BTM_COD_MINOR_CLASS_MASK 0xFC
|
||||||
#define BTM_COD_MINOR_CLASS_MASK 0xFF
|
|
||||||
#define BTM_COD_MAJOR_CLASS_MASK 0x1F
|
#define BTM_COD_MAJOR_CLASS_MASK 0x1F
|
||||||
#define BTM_COD_SERVICE_CLASS_LO_B 0x00E0
|
#define BTM_COD_SERVICE_CLASS_LO_B 0x00E0
|
||||||
#define BTM_COD_SERVICE_CLASS_MASK 0xFFE0
|
#define BTM_COD_SERVICE_CLASS_MASK 0xFFE0
|
||||||
|
#define BTM_COD_RESERVED_2_MASK 0x03
|
||||||
|
|
||||||
|
|
||||||
/* BTM service definitions
|
/* BTM service definitions
|
||||||
|
Loading…
Reference in New Issue
Block a user