mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-19 09:12:45 +00:00
Send file system manifest up on want_config (#4176)
* Send file system manifest up on want_config * Platform specific methods * Helps to actually make the change * Clear
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "Channels.h"
|
||||
#include "Default.h"
|
||||
#include "FSCommon.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "PhoneAPI.h"
|
||||
@@ -47,6 +48,8 @@ void PhoneAPI::handleStartConfig()
|
||||
// even if we were already connected - restart our state machine
|
||||
state = STATE_SEND_MY_INFO;
|
||||
pauseBluetoothLogging = true;
|
||||
filesManifest = getFiles("/", 10);
|
||||
LOG_DEBUG("Got %d files in manifest\n", filesManifest.size());
|
||||
|
||||
LOG_INFO("Starting API client config\n");
|
||||
nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos
|
||||
@@ -149,6 +152,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||
STATE_SEND_CONFIG,
|
||||
STATE_SEND_MODULE_CONFIG,
|
||||
STATE_SEND_OTHER_NODEINFOS, // states progress in this order as the device sends to the client
|
||||
STATE_SEND_FILEMANIFEST,
|
||||
STATE_SEND_COMPLETE_ID,
|
||||
STATE_SEND_PACKETS // send packets or debug strings
|
||||
*/
|
||||
@@ -324,8 +328,9 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
// Advance when we have sent all of our ModuleConfig objects
|
||||
if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) {
|
||||
// Clients sending special nonce don't want to see other nodeinfos
|
||||
state = config_nonce == SPECIAL_NONCE ? STATE_SEND_COMPLETE_ID : STATE_SEND_OTHER_NODEINFOS;
|
||||
state = config_nonce == SPECIAL_NONCE ? STATE_SEND_FILEMANIFEST : STATE_SEND_OTHER_NODEINFOS;
|
||||
config_state = 0;
|
||||
filesManifest.clear();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -340,13 +345,28 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
nodeInfoForPhone.num = 0; // We just consumed a nodeinfo, will need a new one next time
|
||||
} else {
|
||||
LOG_INFO("Done sending nodeinfos\n");
|
||||
state = STATE_SEND_COMPLETE_ID;
|
||||
state = STATE_SEND_FILEMANIFEST;
|
||||
// Go ahead and send that ID right now
|
||||
return getFromRadio(buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SEND_FILEMANIFEST: {
|
||||
LOG_INFO("getFromRadio=STATE_SEND_FILEMANIFEST\n");
|
||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_fileInfo_tag;
|
||||
if (config_state < filesManifest.size()) {
|
||||
fromRadioScratch.fileInfo = filesManifest.at(config_state);
|
||||
config_state++;
|
||||
// last element
|
||||
if (config_state == filesManifest.size()) {
|
||||
state = STATE_SEND_COMPLETE_ID;
|
||||
config_state = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SEND_COMPLETE_ID:
|
||||
LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n");
|
||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag;
|
||||
@@ -401,6 +421,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
|
||||
void PhoneAPI::handleDisconnect()
|
||||
{
|
||||
filesManifest.clear();
|
||||
pauseBluetoothLogging = false;
|
||||
LOG_INFO("PhoneAPI disconnect\n");
|
||||
}
|
||||
@@ -443,6 +464,7 @@ bool PhoneAPI::available()
|
||||
case STATE_SEND_MODULECONFIG:
|
||||
case STATE_SEND_METADATA:
|
||||
case STATE_SEND_OWN_NODEINFO:
|
||||
case STATE_SEND_FILEMANIFEST:
|
||||
case STATE_SEND_COMPLETE_ID:
|
||||
return true;
|
||||
|
||||
@@ -457,7 +479,6 @@ bool PhoneAPI::available()
|
||||
}
|
||||
}
|
||||
return true; // Always say we have something, because we might need to advance our state machine
|
||||
|
||||
case STATE_SEND_PACKETS: {
|
||||
if (!queueStatusPacketForPhone)
|
||||
queueStatusPacketForPhone = service.getQueueStatusForPhone();
|
||||
|
||||
Reference in New Issue
Block a user