Skip to content

Commit 11b8107

Browse files
committed
apps: Add blehcibridge application
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.
1 parent 403ae02 commit 11b8107

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

apps/blehcibridge/pkg.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
pkg.name: apps/blehcibridge
19+
pkg.type: app
20+
pkg.description: BLE controller application exposing HCI over external interface
21+
pkg.author: "Jerzy Kasenberg <[email protected]>"
22+
pkg.homepage: "http://mynewt.apache.org/"
23+
pkg.keywords:
24+
25+
pkg.deps:
26+
- "@apache-mynewt-core/sys/log/stub"
27+
- "@apache-mynewt-core/sys/stats/full"
28+
- "@apache-mynewt-core/kernel/os"
29+
- "@apache-mynewt-core/sys/shell"
30+
- nimble/transport
31+
32+
pkg.req_apis:
33+
- ble_transport
34+
35+
pkg.deps.'CONSOLE_MODE=="full"':
36+
- "@apache-mynewt-core/sys/console/full"
37+
pkg.deps.'CONSOLE_MODE=="minimal":
38+
- "@apache-mynewt-core/sys/console/minimal"
39+
pkg.deps.'CONSOLE_MODE=="stub":
40+
- "@apache-mynewt-core/sys/console/stub"

apps/blehcibridge/src/main.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include <assert.h>
21+
#include <os/mynewt.h>
22+
#include <nimble/ble_hci_trans.h>
23+
24+
static int
25+
forward_cmd_to_controller(uint8_t *cmdbuf, void *arg)
26+
{
27+
(void)arg;
28+
29+
return ble_hci_trans_hs_cmd_tx(cmdbuf);
30+
}
31+
32+
int
33+
forward_acl_to_controller(struct os_mbuf *om, void *arg)
34+
{
35+
(void)arg;
36+
37+
return ble_hci_trans_hs_acl_tx(om);
38+
}
39+
40+
static int
41+
forward_evt_to_host(uint8_t *hci_ev, void *arg)
42+
{
43+
(void)arg;
44+
45+
return ble_hci_trans_ll_evt_tx(hci_ev);
46+
}
47+
48+
int
49+
forward_acl_to_host(struct os_mbuf *om, void *arg)
50+
{
51+
(void)arg;
52+
53+
return ble_hci_trans_ll_acl_tx(om);
54+
}
55+
56+
int
57+
main(void)
58+
{
59+
/* Initialize OS */
60+
sysinit();
61+
62+
ble_hci_trans_cfg_hs(forward_evt_to_host, NULL, forward_acl_to_host, NULL);
63+
ble_hci_trans_cfg_ll(forward_cmd_to_controller, NULL, forward_acl_to_controller, NULL);
64+
65+
while (1) {
66+
os_eventq_run(os_eventq_dflt_get());
67+
}
68+
return 0;
69+
}

apps/blehcibridge/syscfg.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
syscfg.defs:
20+
CONSOLE_MODE:
21+
description: Which console to use
22+
value: stub
23+
choices:
24+
- full
25+
- minimal
26+
- stub
27+
28+
syscfg.vals:
29+
# Default task settings
30+
OS_MAIN_STACK_SIZE: 64
31+
# Use USB transport by default
32+
BLE_HCI_TRANSPORT: usb
33+
34+
SHELL_TASK: 1
35+
36+
BLE_HCI_BRIDGE: 1

0 commit comments

Comments
 (0)