ADD my candidate applications
Some checks failed
Build test application / build-cli-v1 (debug, DISCO_H747I, tests-bike-computer-bike-system) (push) Failing after 2s
Build test application / build-cli-v1 (debug, DISCO_H747I, tests-bike-computer-sensor-device) (push) Failing after 3s
Build test application / build-cli-v1 (debug, DISCO_H747I, tests-bike-computer-speedometer) (push) Failing after 3s
Some checks failed
Build test application / build-cli-v1 (debug, DISCO_H747I, tests-bike-computer-bike-system) (push) Failing after 2s
Build test application / build-cli-v1 (debug, DISCO_H747I, tests-bike-computer-sensor-device) (push) Failing after 3s
Build test application / build-cli-v1 (debug, DISCO_H747I, tests-bike-computer-speedometer) (push) Failing after 3s
This commit is contained in:
parent
f6e3413cf6
commit
86deb5420b
Binary file not shown.
83
my_candidate_applications.cpp
Normal file
83
my_candidate_applications.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include "my_candidate_applications.h"
|
||||
|
||||
#include "mbed_trace.h"
|
||||
#if MBED_CONF_MBED_TRACE_ENABLE
|
||||
#define TRACE_GROUP "MyCandidateApplications"
|
||||
#endif // MBED_CONF_MBED_TRACE_ENABLE
|
||||
|
||||
update_client::CandidateApplications *createCandidateApplications(
|
||||
BlockDevice &blockDevice,
|
||||
mbed::bd_addr_t storageAddr,
|
||||
mbed::bd_size_t storageSize,
|
||||
uint32_t headerSize,
|
||||
uint32_t nSlots
|
||||
){
|
||||
tr_debug("Create my candidate application");
|
||||
update_client::CandidateApplications* candidate = new bike_computer::MyCandidateApplications(blockDevice, storageAddr, storageSize, headerSize, nSlots);
|
||||
return candidate;
|
||||
}
|
||||
|
||||
namespace bike_computer {
|
||||
|
||||
MyCandidateApplications::MyCandidateApplications(
|
||||
BlockDevice &blockDevice,
|
||||
mbed::bd_addr_t storageAddr,
|
||||
mbed::bd_size_t storageSize,
|
||||
uint32_t headerSize,
|
||||
uint32_t nSlots
|
||||
) : update_client::CandidateApplications(blockDevice, storageAddr, storageSize, headerSize, nSlots) {
|
||||
|
||||
}
|
||||
|
||||
uint32_t MyCandidateApplications::getSlotForCandidate() {
|
||||
tr_debug("Get slot for candidate");
|
||||
|
||||
uint32_t nbrOfSlots = getNbrOfSlots();
|
||||
|
||||
for (uint32_t slotIndex = 0; slotIndex < nbrOfSlots; slotIndex++) {
|
||||
if (! getBlockDeviceApplication(slotIndex).isValid()) {
|
||||
return slotIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// return the slot of the oldest firmware candidates
|
||||
uint32_t oldestSlotIndex = 0;
|
||||
uint64_t oldestFirmwareVersion = getBlockDeviceApplication(oldestSlotIndex).getFirmwareVersion();
|
||||
for (uint32_t slotIndex = 1; slotIndex < nbrOfSlots; slotIndex++) {
|
||||
mbed::bd_addr_t candidateAddress = 0;
|
||||
mbed::bd_size_t slotSize = 0;
|
||||
getCandidateAddress(slotIndex, candidateAddress, slotSize);
|
||||
tr_debug("Checking application at slot %" PRIu32 " (address 0x%" PRIx64 ", size %" PRIu64 ")",
|
||||
slotIndex, candidateAddress, slotSize);
|
||||
|
||||
if (getBlockDeviceApplication(slotIndex).getFirmwareVersion() < oldestFirmwareVersion) {
|
||||
oldestSlotIndex = slotIndex;
|
||||
oldestFirmwareVersion = getBlockDeviceApplication(slotIndex).getFirmwareVersion();
|
||||
}
|
||||
}
|
||||
return oldestSlotIndex;
|
||||
}
|
||||
|
||||
//uint32_t MyCandidateApplications::getSlotForCandidate() {
|
||||
// mbed::bd_addr_t _storageAddress = MBED_CONF_UPDATE_CLIENT_STORAGE_ADDRESS;
|
||||
// tr_debug("Get slot for candidate");
|
||||
//
|
||||
// FlashIAPBlockDevice flashIAPBlockDevice(MBED_ROM_START, MBED_ROM_SIZE);
|
||||
// int ret = flashIAPBlockDevice.init();
|
||||
//
|
||||
// if(ret == 0){
|
||||
// for (int i = 0; i < getNbrOfSlots(); i++) {
|
||||
// mbed::bd_addr_t headerAddress = HEADER_ADDR - MBED_ROM_START;
|
||||
// mbed::bd_addr_t applicationAddress = _storageAddress + i * getSlotSize();
|
||||
// update_client::BlockDeviceApplication activeApplication(flashIAPBlockDevice, headerAddress, applicationAddress);
|
||||
// update_client::UCErrorCode rc = activeApplication.checkApplication();
|
||||
//
|
||||
// if (update_client::UCErrorCode::UC_ERR_NONE != rc) {
|
||||
// return _storageAddress + i * getSlotSize();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
}
|
24
my_candidate_applications.h
Normal file
24
my_candidate_applications.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "update-client/candidate_applications.hpp"
|
||||
|
||||
namespace bike_computer {
|
||||
class MyCandidateApplications : public update_client::CandidateApplications {
|
||||
public:
|
||||
MyCandidateApplications(
|
||||
BlockDevice &blockDevice,
|
||||
mbed::bd_addr_t storageAddr,
|
||||
mbed::bd_size_t storageSize,
|
||||
uint32_t headerSize,
|
||||
uint32_t nSlots
|
||||
);
|
||||
virtual uint32_t getSlotForCandidate() override;
|
||||
};
|
||||
}
|
||||
|
||||
update_client::CandidateApplications *createCandidateApplications(
|
||||
BlockDevice &blockDevice,
|
||||
mbed::bd_addr_t storageAddr,
|
||||
mbed::bd_size_t storageSize,
|
||||
uint32_t headerSize,
|
||||
uint32_t nSlots
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user