mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-14 05:57:55 +00:00
nimble/ll: Add fake dual mode option
This adds option to enable some hacks to allow controller to be initialized by dual-mode host. It basically fakes some HCI commands that we do not support since they are not relevant for LE or replies for commands that we do support but need to be updated for BR/EDR features. This allows for NimBLE controller to be used as a Bluetooth controller e.g. in Windows 10, at least to some extent. This option is not intended to be used for production setup, it should be only used for testing purposes.
This commit is contained in:
@@ -1571,6 +1571,62 @@ ble_ll_hci_status_params_cmd_proc(const uint8_t *cmdbuf, uint8_t len,
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_HBD_FAKE_DUAL_MODE)
|
||||
static int
|
||||
ble_ll_hci_cmd_fake_dual_mode(uint16_t opcode, uint8_t *cmdbuf, uint8_t len,
|
||||
uint8_t *rspbuf, uint8_t *rsplen)
|
||||
{
|
||||
int rc;
|
||||
|
||||
switch (opcode) {
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_LINK_CTRL, 0x01): /* Inquiry */
|
||||
rc = BLE_ERR_MAX + 1;
|
||||
break;
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_LINK_CTRL, 0x02): /* Inquiry Cancel */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x13): /* Write Local Name */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x18): /* Write Page Timeout */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x1a): /* Write Scan Enable */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x1c): /* Write Page Scan Activity */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x1e): /* Write Inquiry Scan Activity */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x20): /* Write Authentication Enable */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x24): /* Write Class Of Device */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x33): /* Host Buffer Size */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x45): /* Write Inquiry Mode */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x52): /* Write Extended Inquiry Response */
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x6d): /* Write LE Host Support */
|
||||
rc = 0;
|
||||
break;
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x58): /* Read Inquiry Response Transmit Power Level */
|
||||
rspbuf[0] = 0x04;
|
||||
*rsplen = 1;
|
||||
rc = 0;
|
||||
break;
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT):
|
||||
put_le64(rspbuf, 0x877bffdbfe0ffebf);
|
||||
*rsplen = 8;
|
||||
rc = 0;
|
||||
break;
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_BUF_SIZE):
|
||||
put_le16(rspbuf, 255);
|
||||
rspbuf[2] = 0;
|
||||
put_le16(rspbuf + 3, 4);
|
||||
put_le16(rspbuf + 5, 0);
|
||||
*rsplen = 7;
|
||||
rc = 0;
|
||||
break;
|
||||
case BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_SUPP_STATES):
|
||||
put_le64(rspbuf, 0x000003ffffffffff);
|
||||
*rsplen = 8;
|
||||
rc = 0;
|
||||
break;
|
||||
default:
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Called to process an HCI command from the host.
|
||||
*
|
||||
@@ -1614,6 +1670,14 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
|
||||
/* Assume response length is zero */
|
||||
rsplen = 0;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_HBD_FAKE_DUAL_MODE)
|
||||
rc = ble_ll_hci_cmd_fake_dual_mode(opcode, cmd->data, cmd->length,
|
||||
rspbuf, &rsplen);
|
||||
if (rc >= 0) {
|
||||
goto send_cc_cs;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (ogf) {
|
||||
case BLE_HCI_OGF_LINK_CTRL:
|
||||
rc = ble_ll_hci_link_ctrl_cmd_proc(cmd->data, cmd->length, ocf);
|
||||
@@ -1648,6 +1712,9 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
|
||||
rc += (BLE_ERR_MAX + 1);
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_HBD_FAKE_DUAL_MODE)
|
||||
send_cc_cs:
|
||||
#endif
|
||||
/* If no response is generated, we free the buffers */
|
||||
BLE_LL_ASSERT(rc >= 0);
|
||||
if (rc <= BLE_ERR_MAX) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
syscfg.defs:
|
||||
BLE_LL_HBD_FAKE_DUAL_MODE:
|
||||
description: >
|
||||
This enables hacks to allow initialize controler as dual-mode
|
||||
device. It can be initialized and used by Windows 10 to some
|
||||
extent.
|
||||
value: 0
|
||||
@@ -559,3 +559,7 @@ syscfg.restrictions:
|
||||
- BLE_LL_PUBLIC_DEV_ADDR <= 0xffffffffffff
|
||||
- BLE_LL_PA == 0 || BLE_LL_PA_GPIO >= 0
|
||||
- BLE_LL_LNA == 0 || BLE_LL_LNA_GPIO >= 0
|
||||
|
||||
$import:
|
||||
# "Here be dragons" settings
|
||||
- "@apache-mynewt-nimble/nimble/controller/syscfg.hbd.yml"
|
||||
|
||||
Reference in New Issue
Block a user