mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 09:42:35 +00:00
WIP nimble now builds
This commit is contained in:
parent
2645730329
commit
102085808f
@ -2,13 +2,26 @@
|
|||||||
|
|
||||||
You probably don't care about this section - skip to the next one.
|
You probably don't care about this section - skip to the next one.
|
||||||
|
|
||||||
- Nimble getting started https://espressif-esp-idf.readthedocs-hosted.com/zh_CN/release-v3.3/api-reference/bluetooth/nimble/index.html#overview? could it work with arduino esp-idf 4.2
|
Nimble tasks:
|
||||||
- update protocol description per cyclomies
|
|
||||||
- update faq with antennas https://meshtastic.discourse.group/t/range-test-ideas-requested/738/2
|
- Nimble getting started https://espressif-esp-idf.readthedocs-hosted.com/zh_CN/release-v3.3/api-reference/bluetooth/nimble/index.html#overview? could it work with arduino esp-idf 4.2
|
||||||
- update faq on recommended android version and phones
|
- implement nimble device api
|
||||||
- add help link inside the app, reference a page on the wiki
|
- setup advertising https://mynewt.apache.org/latest/tutorials/ble/bleprph/bleprph-sections/bleprph-gap-event.html
|
||||||
- turn on amazon reviews support
|
- add security
|
||||||
- add a tablet layout (with map next to messages) in the android app
|
- test with app
|
||||||
|
- restart advertising after client disconnects
|
||||||
|
- make sleep work
|
||||||
|
- check BLE handle stability
|
||||||
|
- apply nimble RPA patches
|
||||||
|
- start RPA long test
|
||||||
|
- implement nimble software update api
|
||||||
|
|
||||||
|
* update protocol description per cyclomies email thread
|
||||||
|
* update faq with antennas https://meshtastic.discourse.group/t/range-test-ideas-requested/738/2
|
||||||
|
* update faq on recommended android version and phones
|
||||||
|
* add help link inside the app, reference a page on the wiki
|
||||||
|
* turn on amazon reviews support
|
||||||
|
* add a tablet layout (with map next to messages) in the android app
|
||||||
|
|
||||||
# Medium priority
|
# Medium priority
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ src_filter =
|
|||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
debug_init_break = tbreak setup
|
debug_init_break = tbreak setup
|
||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags} -Wall -Wextra -Isrc/esp32 -mfix-esp32-psram-cache-issue
|
${env.build_flags} -Wall -Wextra -Isrc/esp32 -mfix-esp32-psram-cache-issue -lnimble
|
||||||
# Hmm - this doesn't work yet
|
# Hmm - this doesn't work yet
|
||||||
# board_build.ldscript = linker/esp32.extram.bss.ld
|
# board_build.ldscript = linker/esp32.extram.bss.ld
|
||||||
lib_ignore = segger_rtt
|
lib_ignore = segger_rtt
|
||||||
|
@ -324,11 +324,85 @@ void loopBLE()
|
|||||||
bluetoothRebootCheck();
|
bluetoothRebootCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This routine is called multiple times, once each time we come back from sleep
|
||||||
|
void reinitBluetooth()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Starting bluetooth\n");
|
||||||
|
|
||||||
|
// Note: these callbacks might be coming in from a different thread.
|
||||||
|
BLEServer *serve = initBLE(
|
||||||
|
[](uint32_t pin) {
|
||||||
|
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
|
||||||
|
screen.startBluetoothPinScreen(pin);
|
||||||
|
},
|
||||||
|
[]() { screen.stopBluetoothPinScreen(); }, getDeviceName(), HW_VENDOR, optstr(APP_VERSION),
|
||||||
|
optstr(HW_VERSION)); // FIXME, use a real name based on the macaddr
|
||||||
|
createMeshBluetoothService(serve);
|
||||||
|
|
||||||
|
// Start advertising - this must be done _after_ creating all services
|
||||||
|
serve->getAdvertising()->start();
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#include "esp_nimble_hci.h"
|
||||||
|
#include "nimble/nimble_port.h"
|
||||||
|
#include "nimble/nimble_port_freertos.h"
|
||||||
|
|
||||||
|
// Force arduino to keep ble data around
|
||||||
|
bool btInUse()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Given a level between 0-100, update the BLE attribute
|
/// Given a level between 0-100, update the BLE attribute
|
||||||
void updateBatteryLevel(uint8_t level) {}
|
void updateBatteryLevel(uint8_t level)
|
||||||
void deinitBLE() {}
|
{
|
||||||
void loopBLE() {}
|
// FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
void deinitBLE()
|
||||||
|
{
|
||||||
|
// FIXME - do we need to dealloc things? - what needs to stay alive across light sleep?
|
||||||
|
auto ret = nimble_port_stop();
|
||||||
|
assert(ret == ESP_OK);
|
||||||
|
|
||||||
|
nimble_port_deinit(); // teardown nimble datastructures
|
||||||
|
nimble_port_freertos_deinit(); // delete the task
|
||||||
|
|
||||||
|
ret = esp_nimble_hci_and_controller_deinit();
|
||||||
|
assert(ret == ESP_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loopBLE()
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ble_host_task(void *param)
|
||||||
|
{
|
||||||
|
nimble_port_run(); // This function will return only when nimble_port_stop() is executed.
|
||||||
|
// nimble_port_freertos_deinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This routine is called multiple times, once each time we come back from sleep
|
||||||
|
void reinitBluetooth()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Starting bluetooth\n");
|
||||||
|
|
||||||
|
// FIXME - if waking from light sleep, only esp_nimble_hci_init
|
||||||
|
// FIXME - why didn't this version work?
|
||||||
|
// auto res = esp_nimble_hci_and_controller_init();
|
||||||
|
auto res = esp_nimble_hci_init();
|
||||||
|
DEBUG_MSG("BLE result %d\n", res);
|
||||||
|
assert(res == ESP_OK);
|
||||||
|
|
||||||
|
nimble_port_init();
|
||||||
|
|
||||||
|
// FIXME Initialize the required NimBLE host configuration parameters and callbacks
|
||||||
|
// Perform application specific tasks / initialization
|
||||||
|
|
||||||
|
nimble_port_freertos_init(ble_host_task);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
#include "SimpleAllocator.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <BLEDevice.h>
|
#include <BLEDevice.h>
|
||||||
#include <BLEServer.h>
|
#include <BLEServer.h>
|
||||||
#include <BLEUtils.h>
|
#include <BLEUtils.h>
|
||||||
#include "SimpleAllocator.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BLUEDROID_ENABLED
|
#ifdef CONFIG_BLUEDROID_ENABLED
|
||||||
|
|
||||||
@ -22,9 +22,8 @@ uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue);
|
|||||||
using StartBluetoothPinScreenCallback = std::function<void(uint32_t pass_key)>;
|
using StartBluetoothPinScreenCallback = std::function<void(uint32_t pass_key)>;
|
||||||
using StopBluetoothPinScreenCallback = std::function<void(void)>;
|
using StopBluetoothPinScreenCallback = std::function<void(void)>;
|
||||||
|
|
||||||
BLEServer *initBLE(
|
BLEServer *initBLE(StartBluetoothPinScreenCallback startBtPinScreen, StopBluetoothPinScreenCallback stopBtPinScreen,
|
||||||
StartBluetoothPinScreenCallback startBtPinScreen, StopBluetoothPinScreenCallback stopBtPinScreen,
|
std::string devName, std::string hwVendor, std::string swVersion, std::string hwVersion = "");
|
||||||
std::string devName, std::string hwVendor, std::string swVersion, std::string hwVersion = "");
|
|
||||||
|
|
||||||
/// Add a characteristic that we will delete when we restart
|
/// Add a characteristic that we will delete when we restart
|
||||||
BLECharacteristic *addBLECharacteristic(BLECharacteristic *c);
|
BLECharacteristic *addBLECharacteristic(BLECharacteristic *c);
|
||||||
@ -40,4 +39,5 @@ extern SimpleAllocator btPool;
|
|||||||
/// Given a level between 0-100, update the BLE attribute
|
/// Given a level between 0-100, update the BLE attribute
|
||||||
void updateBatteryLevel(uint8_t level);
|
void updateBatteryLevel(uint8_t level);
|
||||||
void deinitBLE();
|
void deinitBLE();
|
||||||
void loopBLE();
|
void loopBLE();
|
||||||
|
void reinitBluetooth();
|
@ -12,27 +12,6 @@
|
|||||||
|
|
||||||
bool bluetoothOn;
|
bool bluetoothOn;
|
||||||
|
|
||||||
// This routine is called multiple times, once each time we come back from sleep
|
|
||||||
void reinitBluetooth()
|
|
||||||
{
|
|
||||||
DEBUG_MSG("Starting bluetooth\n");
|
|
||||||
|
|
||||||
#ifdef CONFIG_BLUEDROID_ENABLED
|
|
||||||
// Note: these callbacks might be coming in from a different thread.
|
|
||||||
BLEServer *serve = initBLE(
|
|
||||||
[](uint32_t pin) {
|
|
||||||
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
|
|
||||||
screen.startBluetoothPinScreen(pin);
|
|
||||||
},
|
|
||||||
[]() { screen.stopBluetoothPinScreen(); }, getDeviceName(), HW_VENDOR, optstr(APP_VERSION),
|
|
||||||
optstr(HW_VERSION)); // FIXME, use a real name based on the macaddr
|
|
||||||
createMeshBluetoothService(serve);
|
|
||||||
|
|
||||||
// Start advertising - this must be done _after_ creating all services
|
|
||||||
serve->getAdvertising()->start();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable/disable bluetooth.
|
// Enable/disable bluetooth.
|
||||||
void setBluetoothEnable(bool on)
|
void setBluetoothEnable(bool on)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user