Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host: Adding database hash calculation #1

Open
wants to merge 307 commits into
base: micropython_1_4_0
Choose a base branch
from

Conversation

MarceauFillon
Copy link

Database hash calculation using the services, characteristics and descriptors values.

prasad-alatkar and others added 30 commits July 12, 2021 15:36
…telist

* Modify test case `*_wl_bad_args` to accept 0 whitelist entries.
We never include AdvA on primary channel so TxAdd should be set to 0 as
it's RFU in such case.
If scanned chain was truncated due to low buffers for HCI event we may
be already too late to remove next AUX from scheduler and thus can
receive next packet. Just ignore PDU if truncated was already sent.
Add new instance that advertises 1650 bytes of periodic data.
Fix typo in assert which make it never catch intended error.
hal_timer executes from ISR which was preempting LL task
and could result in HCI flow issues if unlucky.
controller/ble_ll_scan: For callouts number of ticks should be used
Those functions are expected to always consume txom.
Host Number of Completed Packets command is special as it doesn't
generate status event and thus is not send with ble_hs_hci_cmd_tx.

We should stil sync sending it with ble_hs_hci_cmd_tx() though to
avoid requesting more than one command buffer from HCI transport
(which may not be able to provide more).
Recently the RIOT IRQ API was extended to support irq_is_enabled(),
so time to switch away from the hacked implementation of
ble_npl_hw_is_in_critical().
When HCI command was received from USB transport cmd_len was not checked
and was used for memcpy.
It could lead to memory corruption if USB stack called this function with
size exceeding maximum command size. This is currently possible scenario
with TinyUSB stack (it will be fixed there as well).
If ble_hs_conn_chan_find_by_scid fails to find channel, it means
that destination CID in L2CAP Disconnection Request is invalid.
Send L2CAP_COMMAND_REJECT_RSP with BLE_L2CAP_SIG_ERR_INVALID_CID
reason.

This is affecting L2CAP/LE/CFC/BV-23-C
If receive data lenght exceeds what was defined in first packet
disconnect with peer.

This is affecting L2CAP/LE/CFC/BV-28-C
…NEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME is not defined).

When `MYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME` is not defined, the existing code always returns 0 as the "tick at which RF will be fully enabled".  However, this causes problems.  For example, in `ble_ll_adv_sm_start()` (ble_ll_adv.c:2743) the calculation of `delta` overflows when the system timer is between 0x80000000 and 0xFFFFFFFF -- causing an incorrect, huge adjustment to be made to the scheduled time, ultimately stopping the advertisements from being sent.
Let's use instance number as sid also, this makes it easier to find
those instances in the air.

Also fix instance numbers in comments.
'own_addr_type' and 'scan_filt_policy' are the same for both PHYs so no
need to keep them separately for each scanp. Also we already had
own_addr_type so usage of this parameter was somewhat inconsistent.
This change moves handling of scanning aux PDUs to separate unit and
thus simplifies code in ble_ll_scan. Basically, once ADV_EXT_IND is
scanned by main scansm, scanning aux PDUs is running as a separate
LL state and is handled by separate code.

Handling on aux PDUs was also refactored a bit, more importantly we
no longer need ref/unref for aux_data which caused lots of issues in
the past - aux_data is always only allocated in ISR context when
ADV_EXT_IND with AuxPtr is received and then can be freed only in
LL context if no subsequent scan is scheduled.

In addition, some changes were done to filtering routines so that now
filtering and address resolution is done only once for each scanned
ext advertising event, i.e. either on ADV_EXT_IND or AUX_ADV_IND.

There is still some legacy code for aux scanner left since it's used
by initiator role. This will be eventually removed once initiator is
refactored to use the same code as generic scanner.
We do not need to restrict TX time after sending LL_PHY_REQ as a master,
this only applies to slave.

This makes LL/CON/CEN/BV-53-C pass instead of being inconclusive due to
data fragmentation done by IUT between LL_PHY_REQ and LL_PHU_UPDATE_IND.

Ref: Core 5.x, Vol. 6, Part B, section 5.1.10.1
This is required for updated install script to work properly.
If adv item is removed from scheduler we should drop event instead
of just sending done event.

Sending done event instead can cause issues on extended advertising
instances if we remove aux items since it does not clear aux_active
flag. As a result, when done even is handled and we reached max_events,
HCI event will not be sent since it waits for done event for secondary
channel but that one won't cone since aux items are already removed.
sjanc and others added 28 commits December 30, 2021 12:50
Dummy BSP could be getting out of sync with Mynewt BSP leading to
compile errors.
app_key is expected to be a pointer to pointer and not
artay of pointers.
meta was used uninitialed in this log.
btaddr is not used anywhere in ble_hci_sock_cmdevt_tx function.
This typo caused advertising to break on 1st received req PDU...
The possible combination of options when setting legacy_pdu:=1
in `struct ble_gap_ext_adv_params` was not obvious to API users.
This commit improves the API by i) adding accoring documentation
and ii) adding a validity check into ble_gap_ext_adv_params_tx().
Proper OGF for vendor specific cmd: 0x3F
The BMD-345 modules are preprogrammed from the factory with a unique
public Bluetooth device address stored in the CUSTOMER[0] and
CUSTOMER[1] registers of the User Information Configuration Registers
(UICR).
strl* methods are not always available, let's use snprintf()
for string copy/concat actions in parse_dev_addr, as it allows
us to keep buffer overflow control and NULL termination of string.
ble_hs_id_copy_addr() is used whenever deprecated value was used
for getting public address.
Direct dependency on controller is incorrect when
controller runs on another core.
This adds some definitions for PA/LNA support. The actual support is
implemented in phy and front-end driver.
This adds support for PA/LNA on nRF52 phy.

PA/LNA is controlled using PPI CH6 (enable) and CH7 (disable). At the
moment no separate timestamp is used to enable PA/LNA in advance, it's
simply enabled just after ramp-up. This should be fine for front-end
modules with short switch on time like SKY66112 (<800ns).
This adds support for SKY66112 front-end module (PA/LNA).

CTX and CRX signals are controller by phy and shall be configured using
LL syscfg settings for PA/LNA. Other signals can be configured via GPIO
or simply driven externally to spare GPIO pins. It's possible to use PA
or LNA only, in such case CPS signal has to be driven via GPIO.
This command allows to override TX power configured with
BLE_LL_TX_PWR_DBM syscfg value. If 0xff is provided BLE_LL_TX_PWR_DBM
TX power is restored.
Set the start_time of the first anchor point of new connection to
entry->end_time+1.

For the 32768 Hz crystal in nrf chip, 1 tick is 30.517us.
The connection state machine use anchor point to store the cpu
ticks and anchor_point_usec to store the remainder. Therefore,
to compensate the inaccuracy of the crystal, the ticks of
anchor_point will be add with 1 once the value of
anchor_point_usec exceed 31. If two connections have same
connection interval, the time difference between the two start
of schedule item will decreased 1, which lead to an overlap.
To prevent this from happenning, we set the start_time of sch
to 1 cpu tick after the end_time of entry.
During sync `duration` argument was introduced, which is not intended
to be in `bt_le_adv_start` - duration of advertising is managed by
events in bt_mesh_adv_queue.
`ble_npl_eventq_get` is waiting for events for duration in tick
units, not ms. This means that we're waiting OS_TICKS_PER_SEC times
to long and catch events that are meant to be missed.
If data received in ble_gattc_write_long_rx_prep() doesn't match
data sent in prepare write request we need not only return error in
function, but also send ATT_Execute_Write_Response with flag set to
BLE_ATT_EXEC_WRITE_F_CANCEL.

This is affecting GATT/CL/GAW/BI-32-C
blehci application is for controller only build with external
interface. In case of dual-core MCUs (NRF5340, DA1469x) controller
runs on second core that may not be able to operate on external
interface. To be able to run blehci like application on dual-core
systems, application side has to route traffic from external interface
transport to internal transport.
So far only one transport package was used, for bridge configuration
application must include two transport packages.
To facilitate this:
- transport package has BLE_HCI_BRIDGE that is set to 1 for dual-core
  bridge configuration
- common syscfg values defined for in all transports are moved
  to transport package (BLE_HCI_EVT_HI_BUF_COUNT..)
- syscfg definitions present in all transport packages are converted to
  syscfg values
- DA1469x and NRF5340 transports in bridge configuration will NOT create
  buffers for commands and events they relay on external transport provided
  buffers
This application is equivalent of blehci for dual-core MCUs.
It allows to forward traffic from external transport (USB/UART)
to BLE core via internal transport.
Transport package should not be included directly.
Instead, nimble/transport should be included and
BLE_HCI_TRANSPORT syscfv value should specify transport,
and this will include correct package.

This commit changes nimble/transport/ram to nimble/transport in
all applications that still have deprecated way of transport
selection.
Function ble_ll_data_buffer_overflow() and ble_ll_hw_error() are executed
from host code, but those are controller functions. They would only work
when host and controller runs on same CPU.
In bridge build when controller code can't be executed this way two transports
(nrf5340/dialog_cmac) provide those functions so UART can be used in bridge
configuration.
This is just workaround till functions are implemented or other way of signaling
those errors is established.
Supports database hash characteristic.
Computes database hash and stores it on first pairing with device.
Computes current hash and compares it with stored hash on reconnection.

See BLE Core spec 5.2 section 7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet