Skip to content

Commit 4051c5b

Browse files
committed
fw: drivers: add da1468x bluetooth code
1 parent 5b5d49c commit 4051c5b

File tree

203 files changed

+19237
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+19237
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!openocd.cfg
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "dialog_utils.h"
18+
19+
// Dialog SDK:
20+
#include "ble_common.h"
21+
22+
#include <bluetooth/gap_le_connect.h>
23+
#include <string.h>
24+
#include <stdbool.h>
25+
26+
bool dialog_utils_dialog_is_addr_type_random(addr_type_t addr_type) {
27+
return (addr_type == PRIVATE_ADDRESS);
28+
}
29+
30+
addr_type_t dialog_utils_local_addr_type_to_dialog(const BTDeviceInternal *address) {
31+
return (address->is_random_address) ? PRIVATE_ADDRESS : PUBLIC_ADDRESS;
32+
}
33+
34+
void dialog_utils_bd_address_to_bt_device(const bd_address_t *addr, BTDeviceInternal *device_out) {
35+
*device_out = (BTDeviceInternal) {};
36+
device_out->is_random_address = dialog_utils_dialog_is_addr_type_random(addr->addr_type);
37+
memcpy(&device_out->address, &addr->addr, sizeof(device_out->address));
38+
}
39+
40+
void dialog_utils_bt_device_to_bd_address(const BTDeviceInternal *device, bd_address_t *addr_out) {
41+
addr_out->addr_type = dialog_utils_local_addr_type_to_dialog(device);
42+
memcpy(addr_out->addr, &device->address, sizeof(addr_out->addr));
43+
}
44+
45+
HciStatusCode ble_error_to_hci_status_error(ble_error_t e) {
46+
switch (e) {
47+
case BLE_STATUS_OK:
48+
return HciStatusCode_Success;
49+
default:
50+
return (e + HciStatusCode_VS_Base);
51+
}
52+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "bonding_sync_impl.h"
18+
#include "hc_protocol/hc_endpoint_bonding_sync.h"
19+
#include "hc_protocol/hc_protocol.h"
20+
21+
#include "kernel/pbl_malloc.h"
22+
#include "system/logging.h"
23+
24+
#include <bluetooth/bonding_sync.h>
25+
26+
#include <stdint.h>
27+
28+
void hc_endpoint_bonding_sync_handler(const HcProtocolMessage *msg) {
29+
switch (msg->command_id) {
30+
case HcMessageID_BondingSync_AddBonding:
31+
bonding_sync_handle_hc_add((const BleBonding *)msg->payload);
32+
break;
33+
case HcMessageID_BondingSync_RemoveBonding:
34+
bonding_sync_handle_hc_remove((const BleBonding *)msg->payload);
35+
break;
36+
37+
default:
38+
PBL_LOG(LOG_LEVEL_ERROR, "Unknown command ID: %"PRIu8, msg->command_id);
39+
break;
40+
}
41+
}
42+
43+
static void prv_send_cmd(HcMessageID_BondingSync cmd_id, const BleBonding *bonding) {
44+
hc_protocol_enqueue_with_payload(HcEndpointID_BondingSync, cmd_id,
45+
(const uint8_t *)bonding, sizeof(*bonding));
46+
}
47+
48+
void hc_endpoint_bonding_sync_add(const BleBonding *bonding) {
49+
prv_send_cmd(HcMessageID_BondingSync_AddBonding, bonding);
50+
}
51+
52+
void hc_endpoint_bonding_sync_remove(const BleBonding *bonding) {
53+
prv_send_cmd(HcMessageID_BondingSync_RemoveBonding, bonding);
54+
}

0 commit comments

Comments
 (0)