MCPcopy Create free account
hub / github.com/SmingHub/Sming / registerDevice

Function registerDevice

Sming/Components/Storage/src/Storage.cpp:31–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31bool registerDevice(Device* device)
32{
33 if(device == nullptr) {
34 return false;
35 }
36 auto devname = device->getName();
37
38 Device::List devices(spiFlash);
39 auto it = std::find(devices.begin(), devices.end(), devname);
40 if(!it) {
41 devices.add(device);
42 device->loadPartitions(*spiFlash, PARTITION_TABLE_OFFSET);
43 debug_i("[Storage] Device '%s' registered", devname.c_str());
44 } else if(*it != *device) {
45 debug_e("[Storage] Another device is already registered with name '%s'", devname.c_str());
46 return false;
47 }
48
49 return true;
50}
51
52bool unRegisterDevice(Device* device)
53{

Callers 4

initFileSystemFunction · 0.85
mountSpiffsFromFileMethod · 0.85
executeMethod · 0.85
initializeFunction · 0.85

Calls 7

findFunction · 0.85
getNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
addMethod · 0.45
loadPartitionsMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected