sforkowany z mirror/meshtastic-firmware
we now BLE notify for the arrival of new messages
rodzic
882b6bd655
commit
e6535f5504
14
TODO.md
14
TODO.md
|
@ -1,20 +1,20 @@
|
|||
# High priority
|
||||
|
||||
* make jtag work on second board
|
||||
* notify phone when rx packets arrive, currently the phone polls at startup only
|
||||
* when notified phone should download messages
|
||||
* have phone use our local node number as its node number (instead of hardwired)
|
||||
* have MeshService keep a node DB by sniffing user messages
|
||||
* have meshservice send location data on mesh (if device has a GPS)
|
||||
* have a state machine return the correct FromRadio packet to the phone, it isn't always going to be a MeshPacket. Do a notify on fromnum to force the radio to read our state machine generated packets
|
||||
* send my_node_num when phone sends WantsNodes
|
||||
* make jtag work on second board
|
||||
* make basic gui. different screens: debug, one page for each user in the user db, last received text message
|
||||
* respond to the WantUsers message
|
||||
* respond to the WantNodes message
|
||||
|
||||
# Medium priority
|
||||
|
||||
* save our node db (and any rx packets waiting for phone) to flash
|
||||
* send correct hw vendor in the bluetooth info
|
||||
* use https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/ association sleep pattern to save power - but see https://github.com/espressif/esp-idf/issues/2070
|
||||
* correctly map nodeids to nodenums, currently we just do a proof of concept by always doing a broadcast
|
||||
* add interrupt detach/sleep mode config to lora radio so we can enable deepsleep without panicing
|
||||
* figure out if we can use PA_BOOST
|
||||
* scrub default radio config settings for bandwidth/range/speed
|
||||
* use a freertos thread to remain blocked reading from recvfromAckTimeout, so that we don't need to keep polling it from our main thread
|
||||
* override peekAtMessage so we can see any messages that pass through our node (even if not broadcast)? would that be useful?
|
||||
|
@ -52,3 +52,5 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w
|
|||
* make message send from android go to service, then to mesh radio
|
||||
* make message receive from radio go through to android
|
||||
* test loopback tx/rx path code without using radio
|
||||
* notify phone when rx packets arrive, currently the phone polls at startup only
|
||||
* figure out if we can use PA_BOOST - yes, it seems to be on both boards
|
|
@ -69,6 +69,7 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
|
|||
result = Update.getError();
|
||||
}
|
||||
swUpdateResultCharacteristic.setValue(&result, 1);
|
||||
swUpdateResultCharacteristic.notify();
|
||||
}
|
||||
else {
|
||||
Serial.println("unexpected write");
|
||||
|
|
|
@ -40,5 +40,4 @@ lib_deps =
|
|||
TinyGPSPlus
|
||||
ESP8266_SSD1306
|
||||
AXP202X_Library
|
||||
CRC32
|
||||
SPI
|
|
@ -14,6 +14,14 @@ static BLECharacteristic meshFromRadioCharacteristic("8ba2bcc2-ee02-4a55-a531-c5
|
|||
static BLECharacteristic meshToRadioCharacteristic("f75c76d2-129e-4dad-a1dd-7866124401e7", BLECharacteristic::PROPERTY_WRITE);
|
||||
static BLECharacteristic meshFromNumCharacteristic("ed9da18c-a800-4f66-a670-aa7547e34453", BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
|
||||
|
||||
/**
|
||||
* Tell any bluetooth clients that the number of rx packets has changed
|
||||
*/
|
||||
void bluetoothNotifyFromNum(uint32_t newValue) {
|
||||
meshFromNumCharacteristic.setValue(newValue);
|
||||
meshFromNumCharacteristic.notify();
|
||||
}
|
||||
|
||||
class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
|
||||
{
|
||||
void onRead(BLECharacteristic *c)
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <BLEService.h>
|
||||
#include <BLEServer.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
BLEService *createMeshBluetoothService(BLEServer* server);
|
||||
|
||||
/**
|
||||
* Tell any bluetooth clients that the number of rx packets has changed
|
||||
*/
|
||||
void bluetoothNotifyFromNum(uint32_t newValue);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <pb_decode.h>
|
||||
#include "mesh.pb.h"
|
||||
#include "MeshService.h"
|
||||
#include "MeshBluetoothService.h"
|
||||
|
||||
/*
|
||||
receivedPacketQueue - this is a queue of messages we've received from the mesh, which we are keeping to deliver to the phone.
|
||||
|
@ -50,8 +51,14 @@ MeshService service;
|
|||
|
||||
#define MAX_PACKETS 32 // max number of packets which can be in flight (either queued from reception or queued for sending)
|
||||
#define MAX_RX_TOPHONE 16 // max number of packets which can be waiting for delivery to android
|
||||
#define MAX_RX_FROMRADIO 4 // max number of packets destined to our queue, we dispatch packets quickly so it doesn't need to be big
|
||||
|
||||
MeshService::MeshService() : packetPool(MAX_PACKETS), toPhoneQueue(MAX_RX_TOPHONE), radio(packetPool, toPhoneQueue)
|
||||
MeshService::MeshService()
|
||||
: packetPool(MAX_PACKETS),
|
||||
toPhoneQueue(MAX_RX_TOPHONE),
|
||||
fromRadioQueue(MAX_RX_FROMRADIO),
|
||||
fromNum(0),
|
||||
radio(packetPool, fromRadioQueue)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -65,6 +72,19 @@ void MeshService::init()
|
|||
void MeshService::loop()
|
||||
{
|
||||
radio.loop(); // FIXME, possibly move radio interaction to own thread
|
||||
|
||||
MeshPacket *mp;
|
||||
uint32_t oldFromNum = fromNum;
|
||||
while((mp = fromRadioQueue.dequeuePtr(0)) != NULL) {
|
||||
// FIXME, process the packet locally to update our node DB, update the LCD screen etc...
|
||||
Serial.printf("FIXME, skipping local processing of fromRadio\n");
|
||||
|
||||
fromNum++;
|
||||
assert(toPhoneQueue.enqueue(mp , 0) == pdTRUE); // FIXME, instead of failing for full queue, delete the oldest mssages
|
||||
|
||||
}
|
||||
if(oldFromNum != fromNum) // We don't want to generate extra notifies for multiple new packets
|
||||
bluetoothNotifyFromNum(fromNum);
|
||||
}
|
||||
|
||||
/// Given a ToRadio buffer parse it and properly handle it (setup radio, owner or send packet into the mesh)
|
||||
|
|
|
@ -19,11 +19,15 @@ class MeshService
|
|||
/// received packets waiting for the phone to process them
|
||||
/// FIXME, change to a DropOldestQueue and keep a count of the number of dropped packets to ensure
|
||||
/// we never hang because android hasn't been there in a while
|
||||
/// FIXME - save this to flash on deep sleep
|
||||
PointerQueue<MeshPacket> toPhoneQueue;
|
||||
|
||||
/// Packets which have just arrived from the radio, ready to be processed by this service and possibly
|
||||
/// forwarded to the phone. Note: not using yet - seeing if I can just handle everything asap in handleFromRadio
|
||||
// PointerQueue<MeshPacket> fromRadioQueue;
|
||||
/// forwarded to the phone.
|
||||
PointerQueue<MeshPacket> fromRadioQueue;
|
||||
|
||||
/// The current nonce for the newest packet which has been queued for the phone
|
||||
uint32_t fromNum;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue