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

Change CRC library #11

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "ArduinoBleOTA",
"version": "1.0.0",
"description": "Bluetooth low energy (BLE) library for uploads",
"keywords": "BLE, OTA, bluetooth, upload, update, arduino, python, android, ios",
"repository":
{
"type": "git",
"url": "https://github.com/vovagorodok/ArduinoBleOTA"
},
"authors":
[
{
"name": "vovagorodok",
"email": "vovagorodok2@gmail.com",
"url": "https://github.com/vovagorodok"
},
{
"name": "dkwach",
"email": "dawid.kwach@gmail.com",
"url": "https://github.com/dkwach"
}
],
"license": "MIT",
"homepage": "https://github.com/vovagorodok/ArduinoBleOTA",
"dependencies":
{
"jandrassy/ArduinoOTA":"^1.0.9",
"robtillaart/CRC":"^0.3.3",
"rlogiacco/CircularBuffer":"^1.3.3",
"arduino-libraries/ArduinoBLE":"^1.3.2",
"h2zero/NimBLE-Arduino":"^1.4.1"
},
"headers": ["ArduinoBleOTA.h", "BleOtaMultiservice.h"],
"frameworks": "arduino",
"platforms": ["*"]
}
11 changes: 0 additions & 11 deletions library.properties

This file was deleted.

2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default_envs =
framework = arduino
lib_deps =
jandrassy/ArduinoOTA@^1.0.9
bakercp/CRC32@^2.0.0
robtillaart/CRC@^0.3.3
rlogiacco/CircularBuffer@^1.3.3

[env:esp32dev]
Expand Down
2 changes: 1 addition & 1 deletion src/BleOtaMultiservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inline bool advertiseBle(const std::string& deviceName,
const std::string& primaryUUID,
const std::string& secondaryUUID)
{
auto* server = BLEDevice::createServer();
auto* server = BLEDevice::getServer();
auto* advertising = server->getAdvertising();

NimBLEAdvertisementData primaryAdvertisementData{};
Expand Down
10 changes: 7 additions & 3 deletions src/BleOtaUploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ void BleOtaUploader::handleBegin(const uint8_t* data, size_t length)
currentLength = 0;
uploading = true;
crc.reset();

crc.setPolynome(0x04C11DB7);
crc.setStartXOR(0xFFFFFFFF);
crc.setEndXOR(0xFFFFFFFF);
crc.setReverseIn(true);
crc.setReverseOut(true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of combinations, I'll check if there is easier way

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue: RobTillaart/CRC#31
Lets see what author think about it

#ifndef BLE_OTA_NO_BUFFER
buffer.clear();
uint32_t bufferSize = withBuffer ? BLE_OTA_BUFFER_SIZE : 0;
Expand Down Expand Up @@ -189,7 +193,7 @@ void BleOtaUploader::handleEnd(const uint8_t* data, size_t length)
uint32_t firmwareCrc;
memcpy(&firmwareCrc, data, length);

if (crc.finalize() != firmwareCrc)
if (crc.getCRC() != firmwareCrc)
{
terminateUpload();
send(CHECKSUM_ERROR);
Expand Down Expand Up @@ -278,7 +282,7 @@ void BleOtaUploader::fillData(const uint8_t* data, size_t length)
#else
storage->write(data[i]);
#endif
crc.update(data[i]);
crc.add(data[i]);
}
}

Expand Down