mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 14:55:46 +00:00
* fixes for various targets (BaseChatMesh not compiling for non-terminal chat targets)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include <helpers/BaseChatMesh.h>
|
||||
#include <base64.hpp>
|
||||
#include <Utils.h>
|
||||
|
||||
mesh::Packet* BaseChatMesh::createSelfAdvert(const char* name) {
|
||||
@@ -152,6 +151,7 @@ void BaseChatMesh::onAckRecv(mesh::Packet* packet, uint32_t ack_crc) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAX_GROUP_CHANNELS
|
||||
int BaseChatMesh::searchChannelsByHash(const uint8_t* hash, mesh::GroupChannel dest[], int max_matches) {
|
||||
int n = 0;
|
||||
for (int i = 0; i < num_channels && n < max_matches; i++) {
|
||||
@@ -161,6 +161,7 @@ int BaseChatMesh::searchChannelsByHash(const uint8_t* hash, mesh::GroupChannel d
|
||||
}
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
void BaseChatMesh::onGroupDataRecv(mesh::Packet* packet, uint8_t type, const mesh::GroupChannel& channel, uint8_t* data, size_t len) {
|
||||
uint8_t txt_type = data[4];
|
||||
@@ -266,6 +267,9 @@ bool BaseChatMesh::addContact(const ContactInfo& contact) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef MAX_GROUP_CHANNELS
|
||||
#include <base64.hpp>
|
||||
|
||||
mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
||||
if (num_channels < MAX_GROUP_CHANNELS) {
|
||||
auto dest = &channels[num_channels];
|
||||
@@ -280,6 +284,11 @@ mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
||||
return NULL; // not supported
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ContactsIterator::hasNext(const BaseChatMesh* mesh, ContactInfo& dest) {
|
||||
if (next_idx >= mesh->num_contacts) return false;
|
||||
|
||||
@@ -36,6 +36,10 @@ public:
|
||||
bool hasNext(const BaseChatMesh* mesh, ContactInfo& dest);
|
||||
};
|
||||
|
||||
#ifndef MAX_CONTACTS
|
||||
#define MAX_CONTACTS 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief abstract Mesh class for common 'chat' client
|
||||
*/
|
||||
@@ -48,8 +52,10 @@ class BaseChatMesh : public mesh::Mesh {
|
||||
int sort_array[MAX_CONTACTS];
|
||||
int matching_peer_indexes[MAX_SEARCH_RESULTS];
|
||||
unsigned long txt_send_timeout;
|
||||
#ifdef MAX_GROUP_CHANNELS
|
||||
mesh::GroupChannel channels[MAX_GROUP_CHANNELS];
|
||||
int num_channels;
|
||||
#endif
|
||||
|
||||
mesh::Packet* composeMsgPacket(const ContactInfo& recipient, uint8_t attempt, const char *text, uint32_t& expected_ack);
|
||||
|
||||
@@ -58,7 +64,9 @@ protected:
|
||||
: mesh::Mesh(radio, ms, rng, rtc, mgr, tables)
|
||||
{
|
||||
num_contacts = 0;
|
||||
#ifdef MAX_GROUP_CHANNELS
|
||||
num_channels = 0;
|
||||
#endif
|
||||
txt_send_timeout = 0;
|
||||
}
|
||||
|
||||
@@ -79,7 +87,9 @@ protected:
|
||||
void onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_idx, const uint8_t* secret, uint8_t* data, size_t len) override;
|
||||
bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) override;
|
||||
void onAckRecv(mesh::Packet* packet, uint32_t ack_crc) override;
|
||||
#ifdef MAX_GROUP_CHANNELS
|
||||
int searchChannelsByHash(const uint8_t* hash, mesh::GroupChannel channels[], int max_matches) override;
|
||||
#endif
|
||||
void onGroupDataRecv(mesh::Packet* packet, uint8_t type, const mesh::GroupChannel& channel, uint8_t* data, size_t len) override;
|
||||
|
||||
public:
|
||||
|
||||
@@ -23,7 +23,8 @@ bool IdentityStore::load(const char *name, mesh::LocalIdentity& id, char display
|
||||
if (file) {
|
||||
loaded = id.readFrom(file);
|
||||
|
||||
int n = min(32, max_name_sz); // up to 32 bytes
|
||||
int n = max_name_sz; // up to 32 bytes
|
||||
if (n > 32) n = 32;
|
||||
file.read((uint8_t *) display_name, n);
|
||||
display_name[n - 1] = 0; // ensure null terminator
|
||||
|
||||
|
||||
Reference in New Issue
Block a user