mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* companion radio: new CMD_SHARE_CONTACT
* room server: push notify loop interval changed to 2 secs
This commit is contained in:
parent
67c7fc070e
commit
65580c76d0
4 changed files with 79 additions and 2 deletions
|
|
@ -107,6 +107,7 @@ static uint32_t _atoi(const char* sp) {
|
|||
#define CMD_RESET_PATH 13
|
||||
#define CMD_SET_ADVERT_LATLON 14
|
||||
#define CMD_REMOVE_CONTACT 15
|
||||
#define CMD_SHARE_CONTACT 16
|
||||
|
||||
#define RESP_CODE_OK 0
|
||||
#define RESP_CODE_ERR 1
|
||||
|
|
@ -229,6 +230,49 @@ class MyMesh : public BaseChatMesh {
|
|||
}
|
||||
}
|
||||
|
||||
int getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]) override {
|
||||
char path[64];
|
||||
char fname[18];
|
||||
|
||||
if (key_len > 8) key_len = 8; // just use first 8 bytes (prefix)
|
||||
mesh::Utils::toHex(fname, key, key_len);
|
||||
sprintf(path, "/bl/%s", fname);
|
||||
|
||||
if (_fs->exists(path)) {
|
||||
File f = _fs->open(path);
|
||||
if (f) {
|
||||
int len = f.read(dest_buf, 255); // currently MAX 255 byte blob len supported!!
|
||||
f.close();
|
||||
return len;
|
||||
}
|
||||
}
|
||||
return 0; // not found
|
||||
}
|
||||
|
||||
bool putBlobByKey(const uint8_t key[], int key_len, const uint8_t src_buf[], int len) override {
|
||||
char path[64];
|
||||
char fname[18];
|
||||
|
||||
if (key_len > 8) key_len = 8; // just use first 8 bytes (prefix)
|
||||
mesh::Utils::toHex(fname, key, key_len);
|
||||
sprintf(path, "/bl/%s", fname);
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
File f = _fs->open(path, FILE_O_WRITE);
|
||||
if (f) { f.seek(0); f.truncate(); }
|
||||
#else
|
||||
File f = _fs->open(path, "w", true);
|
||||
#endif
|
||||
if (f) {
|
||||
int n = f.write(src_buf, len);
|
||||
f.close();
|
||||
if (n == len) return true; // success!
|
||||
|
||||
_fs->remove(path); // blob was only partially written!
|
||||
}
|
||||
return false; // error
|
||||
}
|
||||
|
||||
void writeOKFrame() {
|
||||
uint8_t buf[1];
|
||||
buf[0] = RESP_CODE_OK;
|
||||
|
|
@ -441,6 +485,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// init 'blob store' support
|
||||
_fs->mkdir("/bl");
|
||||
|
||||
loadContacts();
|
||||
_public = addChannel(PUBLIC_GROUP_PSK); // pre-configure Andy's public channel
|
||||
|
||||
|
|
@ -657,6 +704,14 @@ public:
|
|||
} else {
|
||||
writeErrFrame(); // not found, or unable to remove
|
||||
}
|
||||
} else if (cmd_frame[0] == CMD_SHARE_CONTACT) {
|
||||
uint8_t* pub_key = &cmd_frame[1];
|
||||
ContactInfo* recipient = lookupContactByPubKey(pub_key, PUB_KEY_SIZE);
|
||||
if (recipient && shareContactZeroHop(*recipient)) {
|
||||
writeOKFrame();
|
||||
} else {
|
||||
writeErrFrame(); // not found, or unable to send
|
||||
}
|
||||
} else if (cmd_frame[0] == CMD_SYNC_NEXT_MESSAGE) {
|
||||
int out_len;
|
||||
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ struct PostInfo {
|
|||
};
|
||||
|
||||
#define REPLY_DELAY_MILLIS 1500
|
||||
#define PUSH_NOTIFY_DELAY_MILLIS 1000
|
||||
#define SYNC_PUSH_INTERVAL 1000
|
||||
#define PUSH_NOTIFY_DELAY_MILLIS 2000
|
||||
#define SYNC_PUSH_INTERVAL 2000
|
||||
|
||||
#define PUSH_ACK_TIMEOUT_FLOOD 12000
|
||||
#define PUSH_TIMEOUT_BASE 4000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue