Browse Source

Remove "Topic: " prefix from room topic messages

pull/3070/head
Ben Batt 1 week ago
parent
commit
d8dc445fb7
  1. 17
      examples/simple_room_server/MyMesh.cpp
  2. 5
      examples/simple_room_server/MyMesh.h

17
examples/simple_room_server/MyMesh.cpp

@ -68,15 +68,14 @@ void MyMesh::storePost(const mesh::Identity &author, const char *postData) {
void MyMesh::pushPostToClient(ClientInfo *client, PostInfo &post) {
MESH_DEBUG_PRINTLN("room.post: pushPostToClient text=%s", post.text);
pushPostInternal(client, post.post_timestamp, post.author, nullptr, post.text);
pushPostInternal(client, post.post_timestamp, post.author, post.text);
}
void MyMesh::pushTopicToClient(ClientInfo *client) {
pushPostInternal(client, topic_timestamp, self_id, "Topic: ", topic);
pushPostInternal(client, topic_timestamp, self_id, topic);
}
void MyMesh::pushPostInternal(ClientInfo* client, uint32_t timestamp, const mesh::Identity& author,
const char* prefix, const char* text) {
void MyMesh::pushPostInternal(ClientInfo* client, uint32_t timestamp, const mesh::Identity& author, const char* text) {
int len = 0;
memcpy(&reply_data[len], &timestamp, 4);
len += 4; // this is a PAST timestamp... but should be accepted by client
@ -89,12 +88,6 @@ void MyMesh::pushPostInternal(ClientInfo* client, uint32_t timestamp, const mesh
memcpy(&reply_data[len], author.pub_key, 4);
len += 4; // just first 4 bytes
if (prefix) {
int prefix_len = strlen(prefix);
memcpy(&reply_data[len], prefix, prefix_len);
len += prefix_len;
}
int text_len = strlen(text);
memcpy(&reply_data[len], text, text_len);
len += text_len;
@ -770,7 +763,7 @@ void MyMesh::loadRoomPrefs() {
if (file) {
file.read((uint8_t *)&topic[0], sizeof(topic)); // 0
topic[MAX_TOPIC_TEXT_LEN] = '\0';
// next: 144
// next: 151
file.close();
}
@ -787,7 +780,7 @@ void MyMesh::saveRoomPrefs() {
#endif
if (file) {
file.write((uint8_t *)&topic[0], sizeof(topic)); // 0
// next: 144
// next: 151
file.close();
}

5
examples/simple_room_server/MyMesh.h

@ -82,8 +82,7 @@
#define MAX_POST_TEXT_LEN (160-9)
// subtract 7 for "Topic: " prefix
#define MAX_TOPIC_TEXT_LEN (MAX_POST_TEXT_LEN - 7)
#define MAX_TOPIC_TEXT_LEN MAX_POST_TEXT_LEN
struct PostInfo {
mesh::Identity author;
@ -127,7 +126,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
void storePost(const mesh::Identity& author, const char* postData);
void pushPostToClient(ClientInfo* client, PostInfo& post);
void pushTopicToClient(ClientInfo* client);
void pushPostInternal(ClientInfo* client, uint32_t timestamp, const mesh::Identity& author, const char* prefix, const char* text);
void pushPostInternal(ClientInfo* client, uint32_t timestamp, const mesh::Identity& author, const char* text);
uint8_t getUnsyncedCount(ClientInfo* client);
bool processAck(const uint8_t *data);
mesh::Packet* createSelfAdvert();

Loading…
Cancel
Save