mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-07 08:07:40 +03:00
appease cppcheck
This commit is contained in:
parent
2a1f7873f7
commit
f337d7934f
@ -54,10 +54,10 @@ void BluetoothActivity::onEnter() {
|
|||||||
Activity::onEnter();
|
Activity::onEnter();
|
||||||
|
|
||||||
NimBLEDevice::init(DEVICE_NAME);
|
NimBLEDevice::init(DEVICE_NAME);
|
||||||
pServer = NimBLEDevice::createServer();
|
NimBLEServer *pServer = NimBLEDevice::createServer();
|
||||||
pServer->setCallbacks(&serverCallbacks, false);
|
pServer->setCallbacks(&serverCallbacks, false);
|
||||||
pService = pServer->createService(SERVICE_UUID);
|
NimBLEService *pService = pServer->createService(SERVICE_UUID);
|
||||||
pRequestChar = pService->createCharacteristic(
|
NimBLECharacteristic *pRequestChar = pService->createCharacteristic(
|
||||||
REQUEST_CHARACTERISTIC_UUID,
|
REQUEST_CHARACTERISTIC_UUID,
|
||||||
NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_NR
|
NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_NR
|
||||||
);
|
);
|
||||||
@ -116,7 +116,8 @@ void BluetoothActivity::intoState(State newState) {
|
|||||||
{
|
{
|
||||||
// caller sets errorMessage
|
// caller sets errorMessage
|
||||||
file.close();
|
file.close();
|
||||||
if (pServer->getConnectedCount() > 0) {
|
NimBLEServer* pServer = NimBLEDevice::getServer();
|
||||||
|
if (pServer != nullptr && pServer->getConnectedCount() > 0) {
|
||||||
// TODO: send back a response over BLE?
|
// TODO: send back a response over BLE?
|
||||||
pServer->disconnect(pServer->getPeerInfo(0));
|
pServer->disconnect(pServer->getPeerInfo(0));
|
||||||
}
|
}
|
||||||
@ -299,7 +300,7 @@ void BluetoothActivity::onRequest(lfbt_message* msg, size_t msg_len) {
|
|||||||
filepath = OUTPUT_DIRECTORY "/" + filename;
|
filepath = OUTPUT_DIRECTORY "/" + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
PROTOCOL_ASSERT(SdMan.openFileForWrite("BT", filepath, file), "Couldn't open file %s for writing", filepath);
|
PROTOCOL_ASSERT(SdMan.openFileForWrite("BT", filepath, file), "Couldn't open file %s for writing", filepath.c_str());
|
||||||
// TODO: would be neat to check if we have enough space, but SDCardManager doesn't seem to expose that info currently
|
// TODO: would be neat to check if we have enough space, but SDCardManager doesn't seem to expose that info currently
|
||||||
|
|
||||||
txnId = msg->txnId;
|
txnId = msg->txnId;
|
||||||
@ -326,7 +327,7 @@ void BluetoothActivity::onRequest(lfbt_message* msg, size_t msg_len) {
|
|||||||
msg_len - 8 - sizeof(lfbt_msg_client_chunk)
|
msg_len - 8 - sizeof(lfbt_msg_client_chunk)
|
||||||
);
|
);
|
||||||
PROTOCOL_ASSERT(state == STATE_OFFERED || state == STATE_RECEIVING, "Invalid state for client_chunk: %d", state);
|
PROTOCOL_ASSERT(state == STATE_OFFERED || state == STATE_RECEIVING, "Invalid state for client_chunk: %d", state);
|
||||||
PROTOCOL_ASSERT(msg->body.clientChunk.offset == receivedBytes, "Expected chunk %d, got %d", receivedBytes, msg->body.clientChunk.offset);
|
PROTOCOL_ASSERT(msg->body.clientChunk.offset == receivedBytes, "Expected chunk %zu, got %u", receivedBytes, msg->body.clientChunk.offset);
|
||||||
|
|
||||||
size_t written = file.write((uint8_t*)msg->body.clientChunk.body, msg_len - 8 - sizeof(lfbt_msg_client_chunk));
|
size_t written = file.write((uint8_t*)msg->body.clientChunk.body, msg_len - 8 - sizeof(lfbt_msg_client_chunk));
|
||||||
PROTOCOL_ASSERT(written > 0, "Couldn't write to file");
|
PROTOCOL_ASSERT(written > 0, "Couldn't write to file");
|
||||||
|
|||||||
@ -89,10 +89,7 @@ class BluetoothActivity final : public Activity {
|
|||||||
|
|
||||||
RequestCallbacks requestCallbacks;
|
RequestCallbacks requestCallbacks;
|
||||||
|
|
||||||
NimBLEServer *pServer;
|
NimBLECharacteristic *pResponseChar = nullptr;
|
||||||
NimBLEService *pService;
|
|
||||||
NimBLECharacteristic *pRequestChar, *pResponseChar;
|
|
||||||
NimBLEAdvertising *pAdvertising;
|
|
||||||
void startAdvertising();
|
void startAdvertising();
|
||||||
void stopAdvertising();
|
void stopAdvertising();
|
||||||
|
|
||||||
@ -111,8 +108,8 @@ class BluetoothActivity final : public Activity {
|
|||||||
FsFile file;
|
FsFile file;
|
||||||
size_t receivedBytes = 0;
|
size_t receivedBytes = 0;
|
||||||
size_t totalBytes = 0;
|
size_t totalBytes = 0;
|
||||||
char errorMessage[256];
|
char errorMessage[256] = {};
|
||||||
uint32_t txnId;
|
uint32_t txnId = 0;
|
||||||
|
|
||||||
void intoState(State newState);
|
void intoState(State newState);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user