works with phone

1.2-legacy
geeksville 2020-02-02 19:08:04 -08:00
rodzic b799004f0d
commit d34bbffb2d
5 zmienionych plików z 40 dodań i 8 usunięć

12
TODO.md
Wyświetl plik

@ -2,12 +2,13 @@
# High priority
* solder debug headers to board
* 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
* make jtag work
* notify phone when rx packets arrive
* when notified phone should download messages
* have phone use our local node number as its node number (instead of hardwired to 9)
* have MeshService keep a node DB by sniffing user messages
* have meshservice send location data on mesh (if device has a GPS)
* make basic gui. different screens: debug, one page for each user in the user db, last received text message
# Medium priority
@ -49,3 +50,6 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w
* change the partition table to take advantage of the 4MB flash on the wroom: http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
* wrap in nice MeshRadio class
* add mesh send & rx
* 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

Wyświetl plik

@ -28,10 +28,13 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
// or make empty if the queue is empty
if (!mp)
{
Serial.println("toPhone queue is empty");
c->setValue((uint8_t *)"", 0);
}
else
{
Serial.println("delivering toPhone packet to phone");
static FromRadio fradio;
// Encapsulate as a ToRadio packet

Wyświetl plik

@ -87,7 +87,7 @@ ErrorCode MeshRadio::sendTo(NodeNum dest, const uint8_t *buf, size_t len)
// FIXME - for now we do all packets as broadcast
dest = NODENUM_BROADCAST;
assert(len <= 255); // Make sure we don't overflow the tiny max packet size
assert(len <= 255); // Make sure we don't overflow the tiny max packet size
// Note: we don't use sendToWait here because we don't want to wait and for the time being don't require
// reliable delivery
@ -95,6 +95,13 @@ ErrorCode MeshRadio::sendTo(NodeNum dest, const uint8_t *buf, size_t len)
return manager.sendto((uint8_t *)buf, len, dest) ? ERRNO_OK : ERRNO_UNKNOWN;
}
/// enqueue a received packet in rxDest
void MeshRadio::handleReceive(MeshPacket *mp)
{
int res = rxDest.enqueue(mp, 0); // NOWAIT - fixme, if queue is full, delete older messages
assert(res == pdTRUE);
}
void MeshRadio::loop()
{
// FIXME read from radio with recvfromAckTimeout
@ -136,8 +143,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
{
// parsing was successful, queue for our recipient
mp->has_payload = true;
int res = rxDest.enqueue(mp, 0); // NOWAIT - fixme, if queue is full, delete older messages
assert(res == pdTRUE);
handleReceive(mp);
}
}
@ -159,6 +165,10 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
assert(res == ERRNO_OK);
}
pool.release(txp);
bool loopbackTest = false; // if true we will pretend to receive any packets we just sent
if (loopbackTest)
handleReceive(txp);
else
pool.release(txp);
}
}

Wyświetl plik

@ -51,5 +51,8 @@ private:
/// low level send, might block for mutiple seconds
ErrorCode sendTo(NodeNum dest, const uint8_t *buf, size_t len);
/// enqueue a received packet in rxDest
void handleReceive(MeshPacket *p);
};

Wyświetl plik

@ -85,6 +85,18 @@ void MeshService::handleToRadio(std::string s)
sendToMesh(r.variant.packet);
break;
case ToRadio_want_nodes_tag:
Serial.println("FIXME: ignoring want nodes");
break;
case ToRadio_set_radio_tag:
Serial.println("FIXME: ignoring set radio");
break;
case ToRadio_set_owner_tag:
Serial.println("FIXME: ignoring set owner");
break;
default:
Serial.println("Error: unexpected ToRadio variant");
break;