mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* fixes for various targets (BaseChatMesh not compiling for non-terminal chat targets)
This commit is contained in:
parent
a3ce65c770
commit
40c3dfa20b
3 changed files with 22 additions and 2 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
#include <helpers/BaseChatMesh.h>
|
#include <helpers/BaseChatMesh.h>
|
||||||
#include <base64.hpp>
|
|
||||||
#include <Utils.h>
|
#include <Utils.h>
|
||||||
|
|
||||||
mesh::Packet* BaseChatMesh::createSelfAdvert(const char* name) {
|
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 BaseChatMesh::searchChannelsByHash(const uint8_t* hash, mesh::GroupChannel dest[], int max_matches) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (int i = 0; i < num_channels && n < max_matches; i++) {
|
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;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void BaseChatMesh::onGroupDataRecv(mesh::Packet* packet, uint8_t type, const mesh::GroupChannel& channel, uint8_t* data, size_t len) {
|
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];
|
uint8_t txt_type = data[4];
|
||||||
|
|
@ -266,6 +267,9 @@ bool BaseChatMesh::addContact(const ContactInfo& contact) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAX_GROUP_CHANNELS
|
||||||
|
#include <base64.hpp>
|
||||||
|
|
||||||
mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
||||||
if (num_channels < MAX_GROUP_CHANNELS) {
|
if (num_channels < MAX_GROUP_CHANNELS) {
|
||||||
auto dest = &channels[num_channels];
|
auto dest = &channels[num_channels];
|
||||||
|
|
@ -280,6 +284,11 @@ mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) {
|
||||||
|
return NULL; // not supported
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool ContactsIterator::hasNext(const BaseChatMesh* mesh, ContactInfo& dest) {
|
bool ContactsIterator::hasNext(const BaseChatMesh* mesh, ContactInfo& dest) {
|
||||||
if (next_idx >= mesh->num_contacts) return false;
|
if (next_idx >= mesh->num_contacts) return false;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ public:
|
||||||
bool hasNext(const BaseChatMesh* mesh, ContactInfo& dest);
|
bool hasNext(const BaseChatMesh* mesh, ContactInfo& dest);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef MAX_CONTACTS
|
||||||
|
#define MAX_CONTACTS 32
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief abstract Mesh class for common 'chat' client
|
* \brief abstract Mesh class for common 'chat' client
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,8 +52,10 @@ class BaseChatMesh : public mesh::Mesh {
|
||||||
int sort_array[MAX_CONTACTS];
|
int sort_array[MAX_CONTACTS];
|
||||||
int matching_peer_indexes[MAX_SEARCH_RESULTS];
|
int matching_peer_indexes[MAX_SEARCH_RESULTS];
|
||||||
unsigned long txt_send_timeout;
|
unsigned long txt_send_timeout;
|
||||||
|
#ifdef MAX_GROUP_CHANNELS
|
||||||
mesh::GroupChannel channels[MAX_GROUP_CHANNELS];
|
mesh::GroupChannel channels[MAX_GROUP_CHANNELS];
|
||||||
int num_channels;
|
int num_channels;
|
||||||
|
#endif
|
||||||
|
|
||||||
mesh::Packet* composeMsgPacket(const ContactInfo& recipient, uint8_t attempt, const char *text, uint32_t& expected_ack);
|
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)
|
: mesh::Mesh(radio, ms, rng, rtc, mgr, tables)
|
||||||
{
|
{
|
||||||
num_contacts = 0;
|
num_contacts = 0;
|
||||||
|
#ifdef MAX_GROUP_CHANNELS
|
||||||
num_channels = 0;
|
num_channels = 0;
|
||||||
|
#endif
|
||||||
txt_send_timeout = 0;
|
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;
|
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;
|
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;
|
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;
|
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;
|
void onGroupDataRecv(mesh::Packet* packet, uint8_t type, const mesh::GroupChannel& channel, uint8_t* data, size_t len) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ bool IdentityStore::load(const char *name, mesh::LocalIdentity& id, char display
|
||||||
if (file) {
|
if (file) {
|
||||||
loaded = id.readFrom(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);
|
file.read((uint8_t *) display_name, n);
|
||||||
display_name[n - 1] = 0; // ensure null terminator
|
display_name[n - 1] = 0; // ensure null terminator
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue