mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-27 07:43:32 +00:00
Add sample applications from mynewt-core repository
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# 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.
|
||||
#
|
||||
pkg.name: apps/blemesh_shell
|
||||
pkg.type: app
|
||||
pkg.description: Sample application for BLE Mesh node with shell support
|
||||
pkg.author: "Michał Narajowski <[email protected]>"
|
||||
pkg.homepage: "http://mynewt.apache.org/"
|
||||
pkg.keywords:
|
||||
|
||||
pkg.deps:
|
||||
- "@apache-mynewt-core/kernel/os"
|
||||
- "@apache-mynewt-core/sys/console/full"
|
||||
- "@apache-mynewt-core/sys/log/full"
|
||||
- "@apache-mynewt-core/sys/stats/full"
|
||||
- "@apache-mynewt-core/sys/shell"
|
||||
- nimble/controller
|
||||
- nimble/host
|
||||
- nimble/host/services/gap
|
||||
- nimble/host/services/gatt
|
||||
- nimble/host/store/ram
|
||||
- nimble/transport/ram
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "os/mynewt.h"
|
||||
#include "mesh/mesh.h"
|
||||
#include "console/console.h"
|
||||
#include "hal/hal_system.h"
|
||||
#include "hal/hal_gpio.h"
|
||||
#include "bsp/bsp.h"
|
||||
#include "shell/shell.h"
|
||||
|
||||
/* BLE */
|
||||
#include "nimble/ble.h"
|
||||
#include "host/ble_hs.h"
|
||||
#include "services/gap/ble_svc_gap.h"
|
||||
#include "mesh/glue.h"
|
||||
#include "mesh/testing.h"
|
||||
|
||||
|
||||
void net_recv_ev(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst,
|
||||
const void *payload, size_t payload_len)
|
||||
{
|
||||
console_printf("Received net packet: ttl 0x%02x ctl 0x%02x src 0x%04x "
|
||||
"dst 0x%04x " "payload_len %d\n", ttl, ctl, src, dst,
|
||||
payload_len);
|
||||
}
|
||||
|
||||
static void model_bound_cb(u16_t addr, struct bt_mesh_model *model,
|
||||
u16_t key_idx)
|
||||
{
|
||||
console_printf("Model bound: remote addr 0x%04x key_idx 0x%04x model %p\n",
|
||||
addr, key_idx, model);
|
||||
}
|
||||
|
||||
static void model_unbound_cb(u16_t addr, struct bt_mesh_model *model,
|
||||
u16_t key_idx)
|
||||
{
|
||||
console_printf("Model unbound: remote addr 0x%04x key_idx 0x%04x "
|
||||
"model %p\n", addr, key_idx, model);
|
||||
}
|
||||
|
||||
static void invalid_bearer_cb(u8_t opcode)
|
||||
{
|
||||
console_printf("Invalid bearer: opcode 0x%02x\n", opcode);
|
||||
}
|
||||
|
||||
static void incomp_timer_exp_cb(void)
|
||||
{
|
||||
console_printf("Incomplete timer expired\n");
|
||||
}
|
||||
|
||||
static struct bt_test_cb bt_test_cb = {
|
||||
.mesh_net_recv = net_recv_ev,
|
||||
.mesh_model_bound = model_bound_cb,
|
||||
.mesh_model_unbound = model_unbound_cb,
|
||||
.mesh_prov_invalid_bearer = invalid_bearer_cb,
|
||||
.mesh_trans_incomp_timer_exp = incomp_timer_exp_cb,
|
||||
};
|
||||
|
||||
static void
|
||||
blemesh_on_reset(int reason)
|
||||
{
|
||||
BLE_HS_LOG(ERROR, "Resetting state; reason=%d\n", reason);
|
||||
}
|
||||
|
||||
static void
|
||||
blemesh_on_sync(void)
|
||||
{
|
||||
console_printf("Bluetooth initialized\n");
|
||||
|
||||
shell_register_default_module("mesh");
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TESTING)) {
|
||||
bt_test_cb_register(&bt_test_cb);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* Initialize OS */
|
||||
sysinit();
|
||||
|
||||
/* Initialize the NimBLE host configuration. */
|
||||
log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
|
||||
LOG_SYSLEVEL);
|
||||
ble_hs_cfg.reset_cb = blemesh_on_reset;
|
||||
ble_hs_cfg.sync_cb = blemesh_on_sync;
|
||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
||||
|
||||
hal_gpio_init_out(LED_2, 0);
|
||||
|
||||
while (1) {
|
||||
os_eventq_run(os_eventq_dflt_get());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Package: apps/blemesh_shell
|
||||
|
||||
syscfg.vals:
|
||||
# Enable the shell task.
|
||||
SHELL_TASK: 1
|
||||
|
||||
# Set log level to info (disable debug logging).
|
||||
LOG_LEVEL: 0
|
||||
|
||||
# Default task settings
|
||||
OS_MAIN_STACK_SIZE: 768
|
||||
|
||||
# Newtmgr is not supported in this app, so disable newtmgr-over-shell.
|
||||
SHELL_NEWTMGR: 0
|
||||
|
||||
MSYS_1_BLOCK_COUNT: 80
|
||||
|
||||
BLE_MESH: 1
|
||||
BLE_MESH_SHELL: 1
|
||||
BLE_MESH_PROV: 1
|
||||
BLE_MESH_RELAY: 1
|
||||
BLE_MESH_PB_ADV: 1
|
||||
BLE_MESH_PB_GATT: 1
|
||||
BLE_MESH_LOW_POWER: 1
|
||||
BLE_MESH_LPN_AUTO: 0
|
||||
BLE_MESH_GATT_PROXY: 1
|
||||
BLE_MESH_LABEL_COUNT: 2
|
||||
BLE_MESH_SUBNET_COUNT: 2
|
||||
BLE_MESH_MODEL_GROUP_COUNT: 2
|
||||
BLE_MESH_APP_KEY_COUNT: 4
|
||||
BLE_MESH_IV_UPDATE_TEST: 1
|
||||
BLE_MESH_TESTING: 1
|
||||
BLE_MESH_FRIEND: 1
|
||||
BLE_MESH_CFG_CLI: 1
|
||||
|
||||
BLE_MESH_DEBUG: 0
|
||||
BLE_MESH_DEBUG_NET: 0
|
||||
BLE_MESH_DEBUG_TRANS: 0
|
||||
BLE_MESH_DEBUG_BEACON: 0
|
||||
BLE_MESH_DEBUG_CRYPTO: 0
|
||||
BLE_MESH_DEBUG_PROV: 0
|
||||
BLE_MESH_DEBUG_ACCESS: 0
|
||||
BLE_MESH_DEBUG_MODEL: 0
|
||||
BLE_MESH_DEBUG_ADV: 0
|
||||
BLE_MESH_DEBUG_LOW_POWER: 0
|
||||
BLE_MESH_DEBUG_FRIEND: 0
|
||||
BLE_MESH_DEBUG_PROXY: 0
|
||||
Reference in New Issue
Block a user