works with phone

This commit is contained in:
geeksville 2020-02-02 19:08:04 -08:00
parent b799004f0d
commit d34bbffb2d
5 changed files with 40 additions and 8 deletions

12
TODO.md
View File

@ -2,12 +2,13 @@
# High priority # High priority
* solder debug headers to board * make jtag work
* make message send from android go to service, then to mesh radio * notify phone when rx packets arrive
* make message receive from radio go through to android * when notified phone should download messages
* test loopback tx/rx path code without using radio * 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 keep a node DB by sniffing user messages
* have meshservice send location data on mesh (if device has a GPS) * 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 # 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 * 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 * wrap in nice MeshRadio class
* add mesh send & rx * 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

View File

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

View File

@ -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 // FIXME - for now we do all packets as broadcast
dest = NODENUM_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 // Note: we don't use sendToWait here because we don't want to wait and for the time being don't require
// reliable delivery // 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; 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() void MeshRadio::loop()
{ {
// FIXME read from radio with recvfromAckTimeout // 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 // parsing was successful, queue for our recipient
mp->has_payload = true; mp->has_payload = true;
int res = rxDest.enqueue(mp, 0); // NOWAIT - fixme, if queue is full, delete older messages handleReceive(mp);
assert(res == pdTRUE);
} }
} }
@ -159,6 +165,10 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
assert(res == ERRNO_OK); 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);
} }
} }

View File

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

View File

@ -85,6 +85,18 @@ void MeshService::handleToRadio(std::string s)
sendToMesh(r.variant.packet); sendToMesh(r.variant.packet);
break; 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: default:
Serial.println("Error: unexpected ToRadio variant"); Serial.println("Error: unexpected ToRadio variant");
break; break;