mirror of
https://github.com/google/pebble.git
synced 2025-07-20 21:31:47 -04:00
fw: drivers: add da1468x bluetooth code
This commit is contained in:
parent
5b5d49cb49
commit
4051c5bb97
203 changed files with 19237 additions and 2 deletions
0
src/bluetooth-fw/da1468x/controller/main/include/.gitignore
vendored
Normal file
0
src/bluetooth-fw/da1468x/controller/main/include/.gitignore
vendored
Normal file
43
src/bluetooth-fw/da1468x/controller/main/include/advert.h
Normal file
43
src/bluetooth-fw/da1468x/controller/main/include/advert.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "advert_state.h"
|
||||
|
||||
// Dialog SDK:
|
||||
#include "ble_common.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ble_evt_gap_adv_completed ble_evt_gap_adv_completed_t;
|
||||
typedef struct BLEAdData BLEAdData;
|
||||
|
||||
ble_error_t advert_set_interval(uint16_t min_slots, uint16_t max_slots);
|
||||
|
||||
//! @return The current state, returned for debugging/logging purposes.
|
||||
//! It's possible this is not AdvertState_Running, in case advertising was paused or is still
|
||||
//! stopping.
|
||||
AdvertState advert_enable(void);
|
||||
|
||||
void advert_set_data(const BLEAdData *ad_data);
|
||||
|
||||
void advert_disable(void);
|
||||
|
||||
void advert_handle_completed(const ble_evt_gap_adv_completed_t *evt);
|
||||
|
||||
void advert_init(void);
|
27
src/bluetooth-fw/da1468x/controller/main/include/aes.h
Normal file
27
src/bluetooth-fw/da1468x/controller/main/include/aes.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define AES_128_BLOCK_SIZE (16)
|
||||
#define AES_128_KEY_SIZE (16)
|
||||
|
||||
bool aes_128_encrypt_block(const uint8_t key[AES_128_KEY_SIZE],
|
||||
const uint8_t plain_text_block[AES_128_BLOCK_SIZE],
|
||||
uint8_t cipher_text_block_out[AES_128_BLOCK_SIZE]);
|
26
src/bluetooth-fw/da1468x/controller/main/include/ble_task.h
Normal file
26
src/bluetooth-fw/da1468x/controller/main/include/ble_task.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <bluetooth/init.h>
|
||||
|
||||
void ble_task_assert_is_executing_on_ble_task(void);
|
||||
|
||||
//! Start the Dialog BLE stack with the given config and block until it's up and running.
|
||||
void ble_task_init(const BTDriverConfig *config);
|
23
src/bluetooth-fw/da1468x/controller/main/include/chip_id.h
Normal file
23
src/bluetooth-fw/da1468x/controller/main/include/chip_id.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dialog_chip_id.h"
|
||||
#include "util/attributes.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
bool dialog_chip_id_copy(DialogChipID *chip_id_out);
|
112
src/bluetooth-fw/da1468x/controller/main/include/connection.h
Normal file
112
src/bluetooth-fw/da1468x/controller/main/include/connection.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gatt_wrapper_types.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct Connection Connection;
|
||||
typedef struct BTDeviceInternal BTDeviceInternal;
|
||||
typedef struct BTDeviceAddress BTDeviceAddress;
|
||||
typedef struct BleConnectionParams BleConnectionParams;
|
||||
typedef struct PPoGATTWorkAroundState PPoGATTWorkAroundState;
|
||||
typedef void (*ConnectionForEachCallback)(Connection *connection, void *data);
|
||||
|
||||
// Call once on boot before doing anything with Bluetooth
|
||||
void connection_module_init(void);
|
||||
|
||||
// Call every time a BT connection is created/destroyed. These ops should
|
||||
// be driven from events received by the ble_task
|
||||
//! @param initial_addr The remote address at the time of connection establishment. See notes
|
||||
//! with the initial_addr field in the Connection struct.
|
||||
//! @param local_addr The local/own address that was used to advertise at the time of connection
|
||||
//! establishment.
|
||||
Connection *connection_create(uint16_t conn_idx, const BTDeviceInternal *initial_addr,
|
||||
const BTDeviceAddress *local_addr, const BleConnectionParams *params);
|
||||
void connection_destroy(Connection *connection);
|
||||
|
||||
// Returns true if the pointer given is in our list of connections
|
||||
bool connection_is_valid(Connection *connection);
|
||||
|
||||
// Enqueues a Gatt Operation to the list of outstanding Gatt Operations in the Connection object.
|
||||
void connection_enqueue_gatt_op(Connection *connection, uintptr_t context_ref,
|
||||
GattRespDest resp_dest, GattOpType op_type);
|
||||
// Dequeues a Gatt Operation from the list of outstanding Gatt Operations in the Connection object.
|
||||
// Returns true if the object was successfully dequeued and false if there are no operations known
|
||||
// to be in progress
|
||||
bool connection_dequeue_gatt_op(Connection *connection, uintptr_t *context_ref,
|
||||
GattRespDest *resp_dest, GattOpType expected_op_type);
|
||||
// Pops the most recent Gatt Operation appended to the list.
|
||||
bool connection_pop_gatt_op(Connection *connection);
|
||||
|
||||
//
|
||||
// Retrieve Connections
|
||||
//
|
||||
|
||||
Connection *connection_by_idx(uint16_t conn_idx);
|
||||
Connection *connection_by_idx_check(uint16_t conn_idx);
|
||||
Connection *connection_by_address(const BTDeviceInternal *addr_buf);
|
||||
Connection *connection_by_address_check(const BTDeviceInternal *addr_out);
|
||||
|
||||
// @note: internal lock will be held for the duration of this call
|
||||
void connection_for_each(ConnectionForEachCallback cb, void *data);
|
||||
|
||||
//
|
||||
// Getters
|
||||
//
|
||||
|
||||
uint16_t connection_get_idx(Connection *connection);
|
||||
//! If valid, gets the updated_addr of the connection, or otherwise the initial_addr.
|
||||
void connection_get_address(const Connection *connection, BTDeviceInternal *addr_buf);
|
||||
//! Gets the local/own address that was used to advertise at the time of connection establishment.
|
||||
void connection_get_local_address(Connection *connection, BTDeviceAddress *addr_buf);
|
||||
void connection_get_address_by_idx_check(uint16_t conn_idx, BTDeviceInternal *addr_out);
|
||||
void connection_get_conn_params(const Connection *connection,
|
||||
BleConnectionParams *params_out);
|
||||
bool connection_is_subscribed_to_gatt_mtu_notifications(const Connection *connection);
|
||||
bool connection_is_gateway(Connection *connection);
|
||||
bool connection_is_subscribed_to_connection_status_notifications(const Connection *connection);
|
||||
bool connection_is_subscribed_to_conn_param_notifications(const Connection *connection);
|
||||
bool connection_should_pin_address(const Connection *connection);
|
||||
bool connection_should_auto_accept_re_pairing(const Connection *connection);
|
||||
bool connection_is_reversed_ppogatt_enabled(const Connection *connection);
|
||||
uint8_t connection_get_last_pairing_result(uint16_t conn_idx);
|
||||
PPoGATTWorkAroundState *connection_get_ppogatt_wa_state(Connection *connection);
|
||||
|
||||
//
|
||||
// Setters - Sets the requested value provided connection_is_valid(connection) returns true
|
||||
//
|
||||
|
||||
void connection_set_gateway(Connection *connection, bool is_gateway);
|
||||
void connection_set_subscribed_to_connection_status_notifications(
|
||||
Connection *connection, bool is_subscribed);
|
||||
void connection_set_subscribed_to_gatt_mtu_notifications(
|
||||
Connection *connection, bool is_subscribed);
|
||||
void connection_set_subscribed_to_conn_param_notifications(
|
||||
Connection *connection, bool is_subscribed);
|
||||
void connection_set_conn_params(Connection *connection, const BleConnectionParams *params);
|
||||
|
||||
void connection_update_address(Connection *connection, const BTDeviceInternal *updated_addr);
|
||||
void connection_set_should_pin_address(Connection *connection, bool should_pin_address);
|
||||
void connection_set_should_auto_accept_re_pairing(Connection *connection,
|
||||
bool should_auto_accept_re_pairing);
|
||||
void connection_set_reversed_ppogatt_enabled(Connection *connection,
|
||||
bool is_reversed_ppogatt_enabled);
|
||||
void connection_set_last_pairing_result(uint16_t conn_idx, uint8_t result);
|
||||
void connection_set_ppogatt_wa_state(Connection *connection, PPoGATTWorkAroundState *state);
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "connection.h"
|
||||
|
||||
#include <bluetooth/bluetooth_types.h>
|
||||
#include <bluetooth/gap_le_connect.h>
|
||||
#include <util/list.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct GattOperation GattOperation;
|
||||
|
||||
typedef enum {
|
||||
ConnectionFlag_IsSubscribedToConnectionStatusNotifications = 0,
|
||||
ConnectionFlag_IsSubscribedToGattMtuNotifications,
|
||||
ConnectionFlag_IsSubscribedToConnParamNotifications,
|
||||
ConnectionFlag_ShouldPinAddress,
|
||||
//! @note The flag in the Connection struct is only relevant during the pairing process.
|
||||
//! Once bonded, the value gets stored in the bonding list (storage.c / device_t).
|
||||
ConnectionFlag_ShouldAutoAcceptRePairing,
|
||||
//! @note The flag in the Connection struct is only relevant during the pairing process.
|
||||
//! Once bonded, the value gets stored in the bonding list (storage.c / device_t).
|
||||
ConnectionFlag_IsReversedPPoGATTEnabled,
|
||||
ConnectionFlagCount,
|
||||
} ConnectionFlag;
|
||||
|
||||
typedef struct Connection {
|
||||
ListNode node;
|
||||
|
||||
uint16_t conn_idx;
|
||||
|
||||
//! Remote address at the time the connection was established.
|
||||
//! This can be the actual connection address OR the resolved address.
|
||||
//! The former is the case for unbonded connections (including yet-to-be-bonded connections).
|
||||
//! The latter is the case for bonded reconnections: if we are bonded (have an IRK) and the
|
||||
//! underlying stack was able to resolve the address before passing the connection establishment
|
||||
//! event to ble_task.
|
||||
BTDeviceInternal initial_addr;
|
||||
|
||||
//! Updated remote address. In case the address got resolved some time after connecting,
|
||||
//! for example after pairing happened, the resolved address will be stored in this field.
|
||||
//! The initial address will stay stored in initial_addr and the resolved address will be set in
|
||||
//! this field. For bonded reconnections, this field will not be used (remain all zeroes).
|
||||
bool has_updated_addr;
|
||||
BTDeviceInternal updated_addr;
|
||||
|
||||
//! Local address at the time the connection was created.
|
||||
BTDeviceAddress local_addr;
|
||||
|
||||
GattOperation *gatt_op_list;
|
||||
|
||||
bool is_gateway;
|
||||
|
||||
//! @see pebble_pairing_service.c
|
||||
uint32_t flags;
|
||||
BleConnectionParams conn_params;
|
||||
uint8_t last_pairing_result;
|
||||
|
||||
//! @see ppogatt_emulated_server_wa.c
|
||||
PPoGATTWorkAroundState *ppogatt_wa_state;
|
||||
} Connection;
|
||||
|
||||
_Static_assert((sizeof(((Connection *)0)->flags) * 8) >= ConnectionFlagCount,
|
||||
"Bitfield 'flags' full!");
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
//! This is a debug utlility that makes it easy to toggle gpios to debug paths which are very
|
||||
//! sensitive to timing.
|
||||
//! To use it simply:
|
||||
//! 1) Call debug_gpio_init() before you want to track things
|
||||
//! 2) Call debug_gpio_toggle() to flip the gpio state
|
||||
|
||||
//! Initializs DEBUG_GPIOs defined in board config and drives them all low
|
||||
void debug_gpio_init(void);
|
||||
|
||||
//! Toggles the debug_gpio from it's current state
|
||||
void debug_gpio_toggle(int debug_gpio_num);
|
||||
|
||||
//! Drives the state of the specified debug gpio
|
||||
void debug_gpio_set_active(int debug_gpio, bool is_active);
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void debug_reboot_reason_print(void);
|
21
src/bluetooth-fw/da1468x/controller/main/include/debugger.h
Normal file
21
src/bluetooth-fw/da1468x/controller/main/include/debugger.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if NO_WATCHDOG
|
||||
void debugger_await(void);
|
||||
#endif
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hc_protocol/hc_endpoint_analytics.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
//! Called once during initialization.
|
||||
void analytics_init(void);
|
||||
|
||||
//! Called every time the Analytics module should reset its state and set all node values to 0.
|
||||
//! Typically called after all analytics have been flushed out to the Main FW (every hour or so).
|
||||
void analytics_reset_nodes(void);
|
||||
|
||||
//! Set a scalar metric
|
||||
//! @param metric The metric to set
|
||||
//! @param val The new value
|
||||
void analytics_set(DialogAnalyticsMetric metric, uint32_t val);
|
||||
|
||||
//! Increment a metric by 1
|
||||
//! @param metric The metric to increment
|
||||
void analytics_inc(DialogAnalyticsMetric metric);
|
||||
|
||||
//! Increment a metric
|
||||
//! @param metric The metric to increment
|
||||
//! @param amount The amount to increment by
|
||||
void analytics_add(DialogAnalyticsMetric metric, uint32_t amount);
|
||||
|
||||
//! Starts a stopwatch that integrates a "rate of things" over time.
|
||||
//! @param metric The metric of the stopwatch to start
|
||||
void analytics_stopwatch_start(DialogAnalyticsMetric metric);
|
||||
|
||||
//! Starts a stopwatch that integrates a "rate of things" over time.
|
||||
//! @param metric The metric for which to start the stopwatch.
|
||||
//! @param count_per_second The rate in number of things per second to count.
|
||||
//! For example, if you want to measure "bytes transferred" over time and know the transfer speed
|
||||
//! is 1024 bytes per second, then you would pass in 1024 as count_per_second.
|
||||
void analytics_stopwatch_start_at_rate(DialogAnalyticsMetric metric, uint32_t count_per_second);
|
||||
|
||||
//! Stops a stopwatch
|
||||
//! @param metric The metric of the stopwatch
|
||||
void analytics_stopwatch_stop(DialogAnalyticsMetric metric);
|
||||
|
||||
//
|
||||
// Consumer API
|
||||
//
|
||||
|
||||
typedef void (*AnalyticsEachCallback)(DialogAnalyticsMetric metric, uint32_t value, void *context);
|
||||
|
||||
void analytics_each(AnalyticsEachCallback cb, void *context);
|
23
src/bluetooth-fw/da1468x/controller/main/include/die.h
Normal file
23
src/bluetooth-fw/da1468x/controller/main/include/die.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/attributes.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
NORETURN reset_due_to_software_failure(void);
|
25
src/bluetooth-fw/da1468x/controller/main/include/dis_impl.h
Normal file
25
src/bluetooth-fw/da1468x/controller/main/include/dis_impl.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct DisInfo DisInfo;
|
||||
|
||||
void device_information_service_init(const DisInfo *dis_info);
|
||||
bool device_information_service_register(uint16_t start_hdl);
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "connection.h"
|
||||
#include "hc_protocol/hc_protocol.h"
|
||||
|
||||
void gap_le_device_name_handle_set(const char *name);
|
||||
|
||||
void gap_le_device_name_handle_request(const BTDeviceInternal *addr);
|
||||
void gap_le_device_name_handle_request_all(void);
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct ble_evt_gattc_browse_svc_t ble_evt_gattc_browse_svc_t;
|
||||
typedef struct ble_evt_gattc_browse_completed_t ble_evt_gattc_browse_completed_t;
|
||||
typedef struct ble_evt_gattc_indication_t ble_evt_gattc_indication_t;
|
||||
|
||||
void gatt_client_discovery_process_service(const ble_evt_gattc_browse_svc_t *service);
|
||||
void gatt_client_discovery_handle_complete(const ble_evt_gattc_browse_completed_t *complete_event);
|
||||
|
||||
bool gatt_client_discovery_filter_service_changed(const ble_evt_gattc_indication_t *evt);
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define DEVICE_INFORMATION_SERVICE_EXPECTED_ATT_STARTING_HANDLE (12)
|
||||
#define HRM_SERVICE_EXPECTED_ATT_STARTING_HANDLE (35)
|
||||
#define HRM_SERVICE_EXPECTED_ATT_ENDING_HANDLE (42)
|
||||
#define PEBBLE_PAIRING_SERVICE_EXPECTED_ATT_STARTING_HANDLE (23)
|
||||
#define PEBBLE_PPOGATT_SERVICE_EXPECTED_ATT_STARTING_HANDLE (0xE000)
|
||||
|
||||
typedef struct BTDriverConfig BTDriverConfig;
|
||||
|
||||
void gatt_local_services_init(const BTDriverConfig *config);
|
||||
void gatt_local_services_register(void);
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ble_gattc.h"
|
||||
|
||||
#include <bluetooth/bluetooth_types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum GattReqSource {
|
||||
GattReqSourceHost,
|
||||
GattReqSourceController,
|
||||
} GattReqSource;
|
||||
|
||||
// Gatt wrappers that call the underlying Dialog Gatt API's.
|
||||
// Wrapped because it also keeps track of the context_ref in a `Connection` object
|
||||
ble_error_t gatt_wrapper_read(uint16_t conn_idx, uint16_t handle, uintptr_t context_ref,
|
||||
GattReqSource source);
|
||||
|
||||
ble_error_t gatt_wrapper_read_by_uuid(uint16_t conn_idx, uint16_t start_h, uint16_t end_h,
|
||||
const att_uuid_t *uuid, uintptr_t context_ref,
|
||||
GattReqSource source);
|
||||
|
||||
ble_error_t gatt_wrapper_write(uint16_t conn_idx, uint16_t handle, uint16_t length,
|
||||
const uint8_t *value, uintptr_t context_ref, GattReqSource source);
|
||||
|
||||
ble_error_t gatt_wrapper_write_no_resp(uint16_t conn_idx, uint16_t handle, uint16_t length,
|
||||
const uint8_t *value);
|
||||
|
||||
// Gatt wrapper callback -- for use when calling gatt_wrapper_read|write from the controller.
|
||||
// Pass the callback fn pointer in context_ref.
|
||||
typedef void (*gatt_wrapper_read_cb)(const ble_evt_gattc_read_completed_t *evt);
|
||||
typedef void (*gatt_wrapper_write_cb)(const ble_evt_gattc_write_completed_t *evt);
|
||||
|
||||
//
|
||||
// Event Handlers (from ble_task)
|
||||
//
|
||||
void gatt_wrapper_handle_read_completed(const ble_evt_gattc_read_completed_t *evt);
|
||||
|
||||
void gatt_wrapper_handle_write_completed(const ble_evt_gattc_write_completed_t *evt);
|
||||
|
||||
void gatt_wrapper_handle_notification(const ble_evt_gattc_notification_t *evt);
|
||||
|
||||
void gatt_wrapper_handle_indication(const ble_evt_gattc_indication_t *evt);
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/list.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum GattOpType {
|
||||
GattOpType_Read,
|
||||
GattOpType_Write
|
||||
} GattOpType;
|
||||
|
||||
typedef enum GattRespDest {
|
||||
GattRespDestNone,
|
||||
GattRespDestHost,
|
||||
GattRespDestController,
|
||||
} GattRespDest;
|
||||
|
||||
typedef struct GattOperation {
|
||||
ListNode node;
|
||||
uintptr_t object_ref;
|
||||
GattRespDest resp_dest;
|
||||
GattOpType op_type;
|
||||
} GattOperation;
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ble_gattc.h"
|
||||
|
||||
void hc_endpoint_gap_service_gattc_read_complete(const ble_evt_gattc_read_completed_t *evt);
|
||||
void hc_endpoint_gap_service_gattc_discover_char(const ble_evt_gattc_discover_char_t *evt);
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ad_ble.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//! Injects an HCI command into Dialog's ROM even if the chip is not configured
|
||||
//! with BLE_STACK_PASSTHROUGH_MODE & BLE_EXTERNAL_HOST. This should be used
|
||||
//! conservatively as it effectively bypasses the dialog SDK stack. It does however
|
||||
//! allow one to add support for things not yet exported as an SDK API (i.e BLE
|
||||
//! Direct Test Modes)
|
||||
bool hci_rom_passthrough_send_cmd(
|
||||
uint16_t ogf, uint16_t ocf, const uint8_t *param_buf, uint8_t param_length);
|
||||
|
||||
//! Commands issued with hci_rom_passthrough_send_cmd() will bubble up
|
||||
//! HCI event(s). This callback is invoked from the app task to handle these events
|
||||
void hci_rom_passthrough_handle_evt(hci_evt_msg_t *msg);
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void host_transport_init_periph(void);
|
||||
void host_transport_init(void);
|
||||
|
||||
typedef enum {
|
||||
SCSPinFunction_Wakeup_GPIO,
|
||||
SCSPinFunction_SPI_CS,
|
||||
} SCSPinFunction;
|
||||
|
||||
// Used by core dump.
|
||||
void host_transport_configure_spi_scs_pin(SCSPinFunction function);
|
||||
void host_transport_set_mcu_int(bool is_ready_to_transact);
|
32
src/bluetooth-fw/da1468x/controller/main/include/hrm_impl.h
Normal file
32
src/bluetooth-fw/da1468x/controller/main/include/hrm_impl.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bluetooth/hrm_service.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void hrm_service_init(bool is_hrm_supported_and_enabled);
|
||||
|
||||
void hrm_service_register(uint16_t start_hdl);
|
||||
|
||||
void hrm_service_handle_measurement(const BleHrmServiceMeasurement *measurement,
|
||||
const BTDeviceInternal *permitted_devices,
|
||||
size_t num_permitted_devices);
|
||||
|
||||
void hrm_service_handle_enable(bool enable);
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// Defined with prefix of `kernel` to allow for code to be shared
|
||||
// between normal firmware the bluetooth firmware.
|
||||
void kernel_heap_init(void);
|
||||
void *kernel_malloc(size_t bytes);
|
||||
void *kernel_zalloc(size_t bytes);
|
||||
void *kernel_malloc_check(size_t bytes);
|
||||
void *kernel_zalloc_check(size_t bytes);
|
||||
void kernel_free(void *ptr);
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "portable.h"
|
||||
|
||||
static inline TickType_t milliseconds_to_ticks(uint32_t milliseconds) {
|
||||
return ((uint64_t)milliseconds * configTICK_RATE_HZ) / 1000;
|
||||
}
|
||||
|
||||
static inline uint32_t ticks_to_milliseconds(TickType_t ticks) {
|
||||
return ((uint64_t)ticks * 1000) / configTICK_RATE_HZ;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct BTDeviceAddress BTDeviceAddress;
|
||||
|
||||
//! @see bt_driver_set_local_address
|
||||
void local_addr_set(bool allow_cycling, const BTDeviceAddress *pinned_address);
|
||||
|
||||
void local_addr_handle_update(const BTDeviceAddress *updated_address);
|
||||
|
||||
void local_addr_handle_adverts_stopped(void);
|
||||
|
||||
void local_addr_handle_disconnection(void);
|
||||
|
||||
void local_addr_init(void);
|
21
src/bluetooth-fw/da1468x/controller/main/include/mcu.h
Normal file
21
src/bluetooth-fw/da1468x/controller/main/include/mcu.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// Stub for the <mcu.h> header.
|
||||
// This will include the right MCU header and ARM core header:
|
||||
#include "sdk_defs.h"
|
||||
|
||||
#undef CMSIS_COMPATIBLE
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct Connection Connection;
|
||||
|
||||
void pebble_pairing_service_init(void);
|
||||
|
||||
//! Registers the Pebble Pairing Service with the ROM stack.
|
||||
//! This needs to happen every time the ROM stack modifies the device configuration, see
|
||||
//! notes in ble_gap.h.
|
||||
void pebble_pairing_service_register(uint16_t start_hdl);
|
||||
|
||||
void pebble_pairing_service_handle_status_change(Connection *connection, uint16_t conn_idx);
|
||||
|
||||
void pebble_pairing_service_handle_gatt_mtu_change(Connection *connection, uint16_t conn_idx);
|
||||
|
||||
void pebble_pairing_service_handle_conn_params_change(Connection *connection, uint16_t conn_idx);
|
21
src/bluetooth-fw/da1468x/controller/main/include/power.h
Normal file
21
src/bluetooth-fw/da1468x/controller/main/include/power.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void power_init(void);
|
||||
|
||||
void power_enter_hibernation(void);
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct Connection Connection;
|
||||
typedef struct HcProtocolMessage HcProtocolMessage;
|
||||
typedef struct PPoGATTWorkAroundState PPoGATTWorkAroundState;
|
||||
|
||||
void ppogatt_service_init(void);
|
||||
void ppogatt_service_register(uint16_t start_hdl);
|
||||
|
||||
bool ppogatt_emulated_server_handle_msg(uint16_t conn_idx, Connection *conn,
|
||||
const HcProtocolMessage *msg);
|
||||
void ppogatt_inject_emulated_ppogatt_service_if_needed(uint16_t conn_idx);
|
||||
|
||||
void ppogatt_enable_emulated_server_wa(void);
|
||||
void ppogatt_emulated_notify_phone_ppogatt_server_found(Connection *conn);
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#include <bluetooth/sm_types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct BTDeviceAddress BTDeviceAddress;
|
||||
|
||||
//! Generates private resolvable address with a random prand.
|
||||
void pra_generate(BTDeviceAddress *address_out);
|
||||
|
||||
//! Generates private resolvable address with a given prand and IRK.
|
||||
void pra_generate_with_prand_and_irk(BTDeviceAddress *address_out,
|
||||
uint32_t prand, const SMIdentityResolvingKey *irk);
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// NOTE: We include the reboot reason in analytics and the tools we use to analyze the analytics are
|
||||
// dependent on the position and ordering of these enumerated values. To keep the analysis tools
|
||||
// simpler, it is best to keep these enums in the same order and add new ones to the end.
|
||||
typedef enum {
|
||||
RebootReasonCode_Unknown = 0,
|
||||
RebootReasonCode_Shutdown,
|
||||
RebootReasonCode_Watchdog,
|
||||
RebootReasonCode_Assert,
|
||||
RebootReasonCode_StackOverflow,
|
||||
RebootReasonCode_HardFault,
|
||||
RebootReasonCode_BreakpointButNoDebuggerAttached,
|
||||
RebootReasonCode_DialogPlatformReset,
|
||||
RebootReasonCode_CoreDumpReentered,
|
||||
RebootReasonCode_CoreDumpRequested,
|
||||
RebootReasonCode_RomError,
|
||||
RebootReasonCode_NMI,
|
||||
} RebootReasonCode;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cookie;
|
||||
RebootReasonCode code;
|
||||
union {
|
||||
uint16_t data16;
|
||||
uint8_t data8[2];
|
||||
};
|
||||
uint32_t extra;
|
||||
} RebootReason;
|
||||
|
||||
void reboot_reason_set(RebootReason *reason);
|
||||
|
||||
bool reboot_reason_get(RebootReason *reason);
|
||||
|
||||
void reboot_reason_clear(void);
|
||||
|
||||
uint32_t reboot_reason_get_crash_lr(void);
|
||||
|
||||
RebootReasonCode reboot_reason_get_last_reboot_reason(void);
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void service_changed_send_indication_to_all(uint16_t start_handle, uint16_t end_handle);
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void hexdump_log_src(int level, const uint8_t *data, size_t length);
|
||||
|
||||
#define PBL_HEXDUMP(level, data, length) \
|
||||
hexdump_log_src(level, data, length);
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/attributes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Log domains
|
||||
|
||||
#define LOG_DOMAIN_MISC 1
|
||||
|
||||
#ifndef LOG_DOMAIN_GATT_DEBUG
|
||||
#define LOG_DOMAIN_GATT_DEBUG 0
|
||||
#endif
|
||||
|
||||
void pbl_log_init(void);
|
||||
void pbl_log_hashed(const uint32_t packed_loghash, ...);
|
||||
void pbl_log(uint8_t log_level, const char *src_filename, int src_line_number,
|
||||
const char *fmt, ...) FORMAT_PRINTF(4, 5);
|
||||
|
||||
void pbl_log_set_level(uint8_t level);
|
||||
uint8_t pbl_log_get_level(void);
|
||||
|
||||
// Log defines/stubs
|
||||
|
||||
#define LOG_LEVEL_ALWAYS 0
|
||||
#define LOG_LEVEL_ERROR 1
|
||||
#define LOG_LEVEL_WARNING 50
|
||||
#define LOG_LEVEL_INFO 100
|
||||
#define LOG_LEVEL_DEBUG 200
|
||||
#define LOG_LEVEL_DEBUG_VERBOSE 255
|
||||
|
||||
#ifdef PBL_LOGS_HASHED
|
||||
#define PBL_SHOULD_LOG(level) (true)
|
||||
#else
|
||||
#define PBL_SHOULD_LOG(level) (level <= LOG_LEVEL_ALWAYS)
|
||||
#endif
|
||||
|
||||
#include "logging/log_hashing.h"
|
||||
|
||||
#define LOG_COLOR_BLACK "BLACK" // Not so useful in general
|
||||
#define LOG_COLOR_RED "RED"
|
||||
#define LOG_COLOR_GREEN "GREEN"
|
||||
#define LOG_COLOR_YELLOW "YELLOW"
|
||||
#define LOG_COLOR_BLUE "BLUE"
|
||||
#define LOG_COLOR_MAGENTA "MAGENTA"
|
||||
#define LOG_COLOR_CYAN "CYAN"
|
||||
#define LOG_COLOR_GREY "GREY"
|
||||
// Reserved for bold. Use sparingly
|
||||
#define LOG_COLOR_LIGHT_GREY "LIGHT_GREY"
|
||||
#define LOG_COLOR_LIGHT_RED "LIGHT_RED"
|
||||
#define LOG_COLOR_LIGHT_GREEN "LIGHT_GREEN"
|
||||
#define LOG_COLOR_LIGHT_YELLOW "LIGHT_YELLOW"
|
||||
#define LOG_COLOR_LIGHT_BLUE "LIGHT_BLUE"
|
||||
#define LOG_COLOR_LIGHT_MAGENTA "LIGHT_MAGENTA"
|
||||
#define LOG_COLOR_LIGHT_CYAN "LIGHT_CYAN"
|
||||
#define LOG_COLOR_WHITE "WHITE"
|
||||
|
||||
// Allow the default color for a src file to be set by defining FILE_LOG_COLOR
|
||||
// Can be called directly with PBL_LOG_COLOR
|
||||
#ifdef FILE_LOG_COLOR
|
||||
#define DEFAULT_LOG_COLOR FILE_LOG_COLOR
|
||||
#else
|
||||
#define DEFAULT_LOG_COLOR LOG_COLOR_GREY
|
||||
#endif
|
||||
|
||||
|
||||
#define SPLIT_64_BIT_ARG(x) (uint32_t)((x >> 32) & 0xFFFFFFFF), (uint32_t)(x & 0xFFFFFFFF)
|
||||
|
||||
#ifndef DEFAULT_LOG_DOMAIN
|
||||
#define DEFAULT_LOG_DOMAIN LOG_DOMAIN_MISC
|
||||
#endif // DEFAULT_LOG_DOMAIN
|
||||
|
||||
#ifdef PBL_LOGS_HASHED
|
||||
|
||||
#define PBL_LOG_D(domain, level, fmt, ...) \
|
||||
do { \
|
||||
if (PBL_SHOULD_LOG(level)) { \
|
||||
if (domain) { \
|
||||
NEW_LOG_HASH(pbl_log_hashed, level, DEFAULT_LOG_COLOR, fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PBL_LOG_COLOR_D(domain, level, color, fmt, ...) \
|
||||
do { \
|
||||
if (PBL_SHOULD_LOG(level)) { \
|
||||
if (domain) { \
|
||||
NEW_LOG_HASH(pbl_log_hashed, level, color, fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#else // PBL_LOGS_HASHED
|
||||
|
||||
#define PBL_LOG_D(domain, level, fmt, ...) \
|
||||
do { \
|
||||
if (PBL_SHOULD_LOG(level)) { \
|
||||
if (domain) { \
|
||||
pbl_log(level, __FILE_NAME__, __LINE__, fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PBL_LOG_COLOR_D(domain, level, color, fmt, ...) \
|
||||
do { \
|
||||
if (PBL_SHOULD_LOG(level)) { \
|
||||
if (domain) { \
|
||||
pbl_log(level, __FILE_NAME__, __LINE__, fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif // PBL_LOGS_HASHED
|
||||
|
||||
#define PBL_LOG(level, fmt, ...) \
|
||||
PBL_LOG_D(DEFAULT_LOG_DOMAIN, level, fmt, ## __VA_ARGS__)
|
||||
|
||||
#define PBL_LOG_COLOR(level, color, fmt, ...) \
|
||||
PBL_LOG_COLOR_D(DEFAULT_LOG_DOMAIN, level, color, fmt, ## __VA_ARGS__)
|
||||
|
||||
#define GATT_LOG_DEBUG(fmt, args...) PBL_LOG_D(LOG_DOMAIN_GATT_DEBUG, LOG_LEVEL_DEBUG, fmt, ## args)
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/attributes.h>
|
||||
#include <util/likely.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
NORETURN passert_failed_no_message(void);
|
||||
|
||||
NORETURN passert_failed_no_message_with_lr(uint32_t lr);
|
||||
|
||||
NORETURN passert_rom_error_no_message_with_errortype(uint32_t error_type_stat);
|
||||
|
||||
#define PBL_ASSERTN(expr) \
|
||||
do { \
|
||||
if (UNLIKELY(!(expr))) { \
|
||||
passert_failed_no_message(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define PBL_ASSERTN_LR(expr, lr) \
|
||||
do { \
|
||||
if (UNLIKELY(!(expr))) { \
|
||||
passert_failed_no_message_with_lr(lr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WTF PBL_ASSERTN(0)
|
55
src/bluetooth-fw/da1468x/controller/main/include/tasks.h
Normal file
55
src/bluetooth-fw/da1468x/controller/main/include/tasks.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "osal.h"
|
||||
|
||||
/*
|
||||
* Centralized Task Management
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
DialogTask_SysInit = 0,
|
||||
DialogTask_Ble,
|
||||
DialogTask_HostTrans,
|
||||
DialogTask_Logging,
|
||||
DialogTask_Last,
|
||||
DialogTask_Error = DialogTask_Last,
|
||||
DialogTask_ISR = 0xF,
|
||||
} DialogTask;
|
||||
|
||||
extern OS_TASK DialogTaskList[DialogTask_Last];
|
||||
|
||||
/*
|
||||
* Task Register
|
||||
* Directly write to DialogTaskList[] for easy compatibility with OS_TASK_CREATE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task Unregister
|
||||
*/
|
||||
void task_unregister_task(OS_TASK task);
|
||||
void task_unregister_dialogtask(DialogTask task);
|
||||
|
||||
/* Given FreeRTOS task handle, return DialogTask enum. DialogTask_Error if not found. */
|
||||
DialogTask task_to_dialogtask(OS_TASK task);
|
||||
|
||||
/* For logging: get the current task ID (will respond with DialogTask_ISR if appropriate) */
|
||||
DialogTask task_get_dialogtask(void);
|
||||
|
||||
/* Dumps to the console, the amount of untouched stack space for each registered task */
|
||||
void tasks_dump_free_space(void);
|
Loading…
Add table
Add a link
Reference in a new issue