* BaseChatMesh::sendMessage(), new est_timeout (OUT) param
This commit is contained in:
@@ -396,8 +396,9 @@ public:
|
|||||||
if (recipient && attempt < 4 && txt_type == TXT_TYPE_PLAIN) {
|
if (recipient && attempt < 4 && txt_type == TXT_TYPE_PLAIN) {
|
||||||
char *text = (char *) &cmd_frame[i];
|
char *text = (char *) &cmd_frame[i];
|
||||||
int tlen = len - i;
|
int tlen = len - i;
|
||||||
|
uint32_t est_timeout;
|
||||||
text[tlen] = 0; // ensure null
|
text[tlen] = 0; // ensure null
|
||||||
int result = sendMessage(*recipient, msg_timestamp, attempt, text, expected_ack_crc);
|
int result = sendMessage(*recipient, msg_timestamp, attempt, text, expected_ack_crc, est_timeout);
|
||||||
// TODO: add expected ACK to table
|
// TODO: add expected ACK to table
|
||||||
if (result == MSG_SEND_FAILED) {
|
if (result == MSG_SEND_FAILED) {
|
||||||
writeErrFrame();
|
writeErrFrame();
|
||||||
@@ -407,7 +408,8 @@ public:
|
|||||||
out_frame[0] = RESP_CODE_SENT;
|
out_frame[0] = RESP_CODE_SENT;
|
||||||
out_frame[1] = (result == MSG_SEND_SENT_FLOOD) ? 1 : 0;
|
out_frame[1] = (result == MSG_SEND_SENT_FLOOD) ? 1 : 0;
|
||||||
memcpy(&out_frame[2], &expected_ack_crc, 4);
|
memcpy(&out_frame[2], &expected_ack_crc, 4);
|
||||||
_serial->writeFrame(out_frame, 6);
|
memcpy(&out_frame[6], &est_timeout, 4);
|
||||||
|
_serial->writeFrame(out_frame, 10);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
writeErrFrame(); // unknown recipient, or unsuported TXT_TYPE_*
|
writeErrFrame(); // unknown recipient, or unsuported TXT_TYPE_*
|
||||||
|
|||||||
@@ -277,7 +277,9 @@ public:
|
|||||||
if (memcmp(command, "send ", 5) == 0) {
|
if (memcmp(command, "send ", 5) == 0) {
|
||||||
if (curr_recipient) {
|
if (curr_recipient) {
|
||||||
const char *text = &command[5];
|
const char *text = &command[5];
|
||||||
int result = sendMessage(*curr_recipient, getRTCClock()->getCurrentTime(), 0, text, expected_ack_crc);
|
uint32_t est_timeout;
|
||||||
|
|
||||||
|
int result = sendMessage(*curr_recipient, getRTCClock()->getCurrentTime(), 0, text, expected_ack_crc, est_timeout);
|
||||||
if (result == MSG_SEND_FAILED) {
|
if (result == MSG_SEND_FAILED) {
|
||||||
Serial.println(" ERROR: unable to send.");
|
Serial.println(" ERROR: unable to send.");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ mesh::Packet* BaseChatMesh::composeMsgPacket(const ContactInfo& recipient, uint3
|
|||||||
return createDatagram(PAYLOAD_TYPE_TXT_MSG, recipient.id, recipient.shared_secret, temp, 5 + text_len);
|
return createDatagram(PAYLOAD_TYPE_TXT_MSG, recipient.id, recipient.shared_secret, temp, 5 + text_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseChatMesh::sendMessage(const ContactInfo& recipient, uint32_t timestamp, uint8_t attempt, const char* text, uint32_t& expected_ack) {
|
int BaseChatMesh::sendMessage(const ContactInfo& recipient, uint32_t timestamp, uint8_t attempt, const char* text, uint32_t& expected_ack, uint32_t& est_timeout) {
|
||||||
mesh::Packet* pkt = composeMsgPacket(recipient, timestamp, attempt, text, expected_ack);
|
mesh::Packet* pkt = composeMsgPacket(recipient, timestamp, attempt, text, expected_ack);
|
||||||
if (pkt == NULL) return MSG_SEND_FAILED;
|
if (pkt == NULL) return MSG_SEND_FAILED;
|
||||||
|
|
||||||
@@ -210,11 +210,11 @@ int BaseChatMesh::sendMessage(const ContactInfo& recipient, uint32_t timestamp,
|
|||||||
int rc;
|
int rc;
|
||||||
if (recipient.out_path_len < 0) {
|
if (recipient.out_path_len < 0) {
|
||||||
sendFlood(pkt);
|
sendFlood(pkt);
|
||||||
txt_send_timeout = futureMillis(calcFloodTimeoutMillisFor(t));
|
txt_send_timeout = futureMillis(est_timeout = calcFloodTimeoutMillisFor(t));
|
||||||
rc = MSG_SEND_SENT_FLOOD;
|
rc = MSG_SEND_SENT_FLOOD;
|
||||||
} else {
|
} else {
|
||||||
sendDirect(pkt, recipient.out_path, recipient.out_path_len);
|
sendDirect(pkt, recipient.out_path, recipient.out_path_len);
|
||||||
txt_send_timeout = futureMillis(calcDirectTimeoutMillisFor(t, recipient.out_path_len));
|
txt_send_timeout = futureMillis(est_timeout = calcDirectTimeoutMillisFor(t, recipient.out_path_len));
|
||||||
rc = MSG_SEND_SENT_DIRECT;
|
rc = MSG_SEND_SENT_DIRECT;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
mesh::Packet* createSelfAdvert(const char* name);
|
mesh::Packet* createSelfAdvert(const char* name);
|
||||||
int sendMessage(const ContactInfo& recipient, uint32_t timestamp, uint8_t attempt, const char* text, uint32_t& expected_ack);
|
int sendMessage(const ContactInfo& recipient, uint32_t timestamp, uint8_t attempt, const char* text, uint32_t& expected_ack, uint32_t& est_timeout);
|
||||||
void resetPathTo(ContactInfo& recipient);
|
void resetPathTo(ContactInfo& recipient);
|
||||||
void scanRecentContacts(int last_n, ContactVisitor* visitor);
|
void scanRecentContacts(int last_n, ContactVisitor* visitor);
|
||||||
ContactInfo* searchContactsByPrefix(const char* name_prefix);
|
ContactInfo* searchContactsByPrefix(const char* name_prefix);
|
||||||
|
|||||||
Reference in New Issue
Block a user