* startSendRaw() now returns false if fail
This commit is contained in:
@@ -234,7 +234,16 @@ void Dispatcher::checkSend() {
|
|||||||
|
|
||||||
uint32_t max_airtime = _radio->getEstAirtimeFor(len)*3/2;
|
uint32_t max_airtime = _radio->getEstAirtimeFor(len)*3/2;
|
||||||
outbound_start = _ms->getMillis();
|
outbound_start = _ms->getMillis();
|
||||||
_radio->startSendRaw(raw, len);
|
bool success = _radio->startSendRaw(raw, len);
|
||||||
|
if (!success) {
|
||||||
|
MESH_DEBUG_PRINTLN("%s Dispatcher::loop(): ERROR: send start failed!", getLogDateTime());
|
||||||
|
|
||||||
|
logTxFail(outbound, outbound->getRawLength());
|
||||||
|
|
||||||
|
releasePacket(outbound); // return to pool
|
||||||
|
outbound = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
outbound_expiry = futureMillis(max_airtime);
|
outbound_expiry = futureMillis(max_airtime);
|
||||||
|
|
||||||
#if MESH_PACKET_LOGGING
|
#if MESH_PACKET_LOGGING
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ public:
|
|||||||
* \brief starts the raw packet send. (no wait)
|
* \brief starts the raw packet send. (no wait)
|
||||||
* \param bytes the raw packet data
|
* \param bytes the raw packet data
|
||||||
* \param len the length in bytes
|
* \param len the length in bytes
|
||||||
|
* \returns true if successfully started
|
||||||
*/
|
*/
|
||||||
virtual void startSendRaw(const uint8_t* bytes, int len) = 0;
|
virtual bool startSendRaw(const uint8_t* bytes, int len) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \returns true if the previous 'startSendRaw()' completed successfully.
|
* \returns true if the previous 'startSendRaw()' completed successfully.
|
||||||
|
|||||||
@@ -77,13 +77,16 @@ uint32_t RadioLibWrapper::getEstAirtimeFor(int len_bytes) {
|
|||||||
return _radio->getTimeOnAir(len_bytes) / 1000;
|
return _radio->getTimeOnAir(len_bytes) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioLibWrapper::startSendRaw(const uint8_t* bytes, int len) {
|
bool RadioLibWrapper::startSendRaw(const uint8_t* bytes, int len) {
|
||||||
state = STATE_TX_WAIT;
|
|
||||||
_board->onBeforeTransmit();
|
_board->onBeforeTransmit();
|
||||||
int err = _radio->startTransmit((uint8_t *) bytes, len);
|
int err = _radio->startTransmit((uint8_t *) bytes, len);
|
||||||
if (err != RADIOLIB_ERR_NONE) {
|
if (err == RADIOLIB_ERR_NONE) {
|
||||||
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startTransmit(%d)", err);
|
state = STATE_TX_WAIT;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startTransmit(%d)", err);
|
||||||
|
idle(); // trigger another startRecv()
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadioLibWrapper::isSendComplete() {
|
bool RadioLibWrapper::isSendComplete() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
void begin() override;
|
void begin() override;
|
||||||
int recvRaw(uint8_t* bytes, int sz) override;
|
int recvRaw(uint8_t* bytes, int sz) override;
|
||||||
uint32_t getEstAirtimeFor(int len_bytes) override;
|
uint32_t getEstAirtimeFor(int len_bytes) override;
|
||||||
void startSendRaw(const uint8_t* bytes, int len) override;
|
bool startSendRaw(const uint8_t* bytes, int len) override;
|
||||||
bool isSendComplete() override;
|
bool isSendComplete() override;
|
||||||
void onSendFinished() override;
|
void onSendFinished() override;
|
||||||
|
|
||||||
|
|||||||
@@ -67,18 +67,19 @@ uint32_t ESPNOWRadio::intID() {
|
|||||||
return n + m;
|
return n + m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESPNOWRadio::startSendRaw(const uint8_t* bytes, int len) {
|
bool ESPNOWRadio::startSendRaw(const uint8_t* bytes, int len) {
|
||||||
// Send message via ESP-NOW
|
// Send message via ESP-NOW
|
||||||
is_send_complete = false;
|
is_send_complete = false;
|
||||||
esp_err_t result = esp_now_send(broadcastAddress, bytes, len);
|
esp_err_t result = esp_now_send(broadcastAddress, bytes, len);
|
||||||
if (result == ESP_OK) {
|
if (result == ESP_OK) {
|
||||||
n_sent++;
|
n_sent++;
|
||||||
ESPNOW_DEBUG_PRINTLN("Send success");
|
ESPNOW_DEBUG_PRINTLN("Send success");
|
||||||
} else {
|
return true;
|
||||||
last_send_result = result;
|
|
||||||
is_send_complete = true;
|
|
||||||
ESPNOW_DEBUG_PRINTLN("Send failed: %d", result);
|
|
||||||
}
|
}
|
||||||
|
last_send_result = result;
|
||||||
|
is_send_complete = true;
|
||||||
|
ESPNOW_DEBUG_PRINTLN("Send failed: %d", result);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ESPNOWRadio::isSendComplete() {
|
bool ESPNOWRadio::isSendComplete() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
int recvRaw(uint8_t* bytes, int sz) override;
|
int recvRaw(uint8_t* bytes, int sz) override;
|
||||||
uint32_t getEstAirtimeFor(int len_bytes) override;
|
uint32_t getEstAirtimeFor(int len_bytes) override;
|
||||||
void startSendRaw(const uint8_t* bytes, int len) override;
|
bool startSendRaw(const uint8_t* bytes, int len) override;
|
||||||
bool isSendComplete() override;
|
bool isSendComplete() override;
|
||||||
void onSendFinished() override;
|
void onSendFinished() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user