說(shuō)明
AdvertiseLE 命令負(fù)責(zé)啟用 LE 廣播。此命令在成功執(zhí)行時(shí)返回零,而在出現(xiàn)任何錯(cuò)誤時(shí)返回負(fù)值。
參數(shù)
唯一必需的參數(shù)決定是發(fā)送還是禁用廣播報(bào)告。要禁用,請(qǐng)使用 0 作為第一個(gè)參數(shù);要啟用,請(qǐng)改用 1。
命令調(diào)用示例
- “AdvertiseLE 1”嘗試在本地藍(lán)牙設(shè)備上啟用低功耗廣播。
- “AdvertiseLE 0”嘗試在本地藍(lán)牙設(shè)備上禁用低功耗廣播。
可能的返回值
- (0) 成功設(shè)置可配對(duì)性模式
- (-4) FUNCTION_ERROR
- (-6) INVALID_PARAMETERS_ERROR
- (-8) INVALID_STACK_ID_ERROR
- (-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
- (-1) BTPS_ERROR_INVALID_PARAMETER
- (-56) BTPS_ERROR_GAP_NOT_INITIALIZED
- (-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
- (-57) BTPS_ERROR_DEVICE_HCI_ERROR
API 調(diào)用
根據(jù)第一個(gè)參數(shù)值:
- GAP_LE_Advertising_Disable(BluetoothStackID)
- GAP_LE_Set_Advertising_Data(BluetoothStackID, (Advertisement_Data_Buffer.AdvertisingData.Advertising_Data[0] + 1), &(Advertisement_Data_Buffer.AdvertisingData))
- GAP_LE_Set_Scan_Response_Data(BluetoothStackID, (Advertisement_Data_Buffer.ScanResponseData.Scan_Response_Data[0] + 1), &(Advertisement_Data_Buffer.ScanResponseData))
- GAP_LE_Advertising_Enable(BluetoothStackID, TRUE, &AdvertisingParameters, &ConnectabilityParameters, GAP_LE_Event_Callback, 0)
API 原型
- int BTPSAPI GAP_LE_Advertising_Disable(unsigned int BluetoothStackID)
- int BTPSAPI GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID, unsigned int Length, Advertising_Data_t *Advertising_Data)
- int BTPSAPI GAP_LE_Set_Scan_Response_Data(unsigned int BluetoothStackID, unsigned int Length, Scan_Response_Data_t *Scan_Response_Data)
- int BTPSAPI GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID, unsigned int Length, Advertising_Data_t *Advertising_Data)
- int BTPSAPI GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID, unsigned int Length, Advertising_Data_t *Advertising_Data)
API 說(shuō)明
- 提供的 GAP_LE_Advertising_Disable 函數(shù)使本地主機(jī)能夠取消(停止)正在進(jìn)行的廣播過(guò)程。如果成功,此函數(shù)返回零;如果出現(xiàn)錯(cuò)誤情況,則返回負(fù)的錯(cuò)誤代碼。
- 提供的 GAP_LE_Set_Advertising_Data 使本地主機(jī)能夠設(shè)置在廣播過(guò)程(通過(guò) GAP_LE_Advertising_Enable 函數(shù)啟動(dòng))中使用的廣播數(shù)據(jù)。如果成功,此函數(shù)返回零;如果出現(xiàn)錯(cuò)誤情況,則返回負(fù)的錯(cuò)誤代碼。
- 提供的 GAP_LE_Set_Scan_Response_Data 函數(shù)使本地主機(jī)能夠設(shè)置在廣播過(guò)程(通過(guò) GAP_LE_Advertising_Enable 函數(shù)啟動(dòng))中使用的廣播數(shù)據(jù)。如果成功,此函數(shù)返回零;如果出現(xiàn)錯(cuò)誤情況,則返回負(fù)的錯(cuò)誤代碼。
- 提供的 GAP_LE_Set_Advertising_Data 函數(shù)使本地主機(jī)能夠設(shè)置在廣播過(guò)程(通過(guò) GAP_LE_Advertising_Enable 函數(shù)啟動(dòng))中使用的廣播數(shù)據(jù)。如果成功,此函數(shù)返回零;如果出現(xiàn)錯(cuò)誤情況,則返回負(fù)的錯(cuò)誤代碼。