Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Give semaphore also on error #70

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/BleServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ std::string updateBuffer;
unsigned long bleLoop = 0;
unsigned long loopTimeSum = 0;
unsigned long loopCount = 0;
unsigned int bleWait = 5;

BleServer::BleServer() = default;

Expand Down Expand Up @@ -186,7 +187,7 @@ void BleServer::loop(VescData *vescData, unsigned long loopTime, unsigned long m
vescBuffer.clear();
}
pCharacteristicVescTx->notify();
delay(1); // bluetooth stack will go into congestion, if too many packets are sent
delay(bleWait); // bluetooth stack will go into congestion, if too many packets are sent
}
}
}
Expand Down Expand Up @@ -347,7 +348,7 @@ void BleServer::onWrite(BLECharacteristic *pCharacteristic) {
Logger::notice(LOG_TAG_BLESERVER, buf);
}
}
delay(1); // needed to give BLE stack some time
delay(bleWait); // needed to give BLE stack some time
}

//NimBLECharacteristicCallbacks::onSubscribe
Expand Down Expand Up @@ -379,7 +380,7 @@ void BleServer::sendValue(NimBLECharacteristic *pCharacteristic, std::string key
pCharacteristic->setValue(ss.str());
pCharacteristic->notify();
ss.str("");
delay(1);
delay(bleWait);
}

static boolean isStringType(String a) { return true; }
Expand Down
1 change: 1 addition & 0 deletions src/CanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ boolean CanDevice::sendCanFrame(const twai_message_t *p_frame) {
//Queue message for transmission
if (twai_transmit(p_frame, pdMS_TO_TICKS(10)) != ESP_OK) {
printf("Failed to queue message for transmission\n");
xSemaphoreGive(mutex_v);
return false;
}
xSemaphoreGive(mutex_v);
Expand Down