Skip to content

Commit

Permalink
WIP - more progress switching to dynamic alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed Feb 23, 2020
1 parent 76100e2 commit bf640be
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class DataCharacteristic : public CallbackCharacteristic
}
};

static BLECharacteristic swUpdateResultCharacteristic("5e134862-7411-4424-ac4a-210937432c77", BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);

static BLECharacteristic *resultC;

class CRC32Characteristic : public CallbackCharacteristic
{
Expand Down Expand Up @@ -96,24 +95,18 @@ class CRC32Characteristic : public CallbackCharacteristic
}
result = Update.getError();
}
swUpdateResultCharacteristic.setValue(&result, 1);
swUpdateResultCharacteristic.notify();
assert(resultC);
resultC->setValue(&result, 1);
resultC->notify();
}
};


static TotalSizeCharacteristic swUpdateTotalSizeCharacteristic;
static DataCharacteristic swUpdateDataCharacteristic;
static CRC32Characteristic swUpdateCRC32Characteristic;


void bluetoothRebootCheck()
{
if (rebootAtMsec && millis() > rebootAtMsec)
ESP.restart();
}


/*
SoftwareUpdateService UUID cb0b9a0b-a84c-4c0d-bdbb-442e3144ee30
Expand All @@ -130,12 +123,14 @@ BLEService *createUpdateService(BLEServer *server)
// Create the BLE Service
BLEService *service = server->createService("cb0b9a0b-a84c-4c0d-bdbb-442e3144ee30");

addWithDesc(service, &swUpdateTotalSizeCharacteristic, "total image size");
addWithDesc(service, &swUpdateDataCharacteristic, "data");
addWithDesc(service, &swUpdateCRC32Characteristic, "crc32");
addWithDesc(service, &swUpdateResultCharacteristic, "result code");
resultC = new (btPool) BLECharacteristic("5e134862-7411-4424-ac4a-210937432c77", BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);

addWithDesc(service, new (btPool) TotalSizeCharacteristic, "total image size");
addWithDesc(service, new (btPool) DataCharacteristic, "data");
addWithDesc(service, new (btPool) CRC32Characteristic, "crc32");
addWithDesc(service, resultC, "result code");

swUpdateResultCharacteristic.addDescriptor(new (btPool) BLE2902()); // Needed so clients can request notification
resultC->addDescriptor(new (btPool) BLE2902()); // Needed so clients can request notification

return service;
}

0 comments on commit bf640be

Please sign in to comment.