| 120 | } |
| 121 | |
| 122 | bool MultiIconPlugin::setTopic(const String& topic, const JsonObjectConst& value) |
| 123 | { |
| 124 | bool isSuccessful = false; |
| 125 | |
| 126 | if (true == topic.startsWith(String(TOPIC_SLOT) + "/")) |
| 127 | { |
| 128 | uint8_t slotId = _MultiIconPlugin::View::MAX_ICON_SLOTS; |
| 129 | bool status = getSlotIdFromTopic(slotId, topic); |
| 130 | |
| 131 | if ((true == status) && |
| 132 | (_MultiIconPlugin::View::MAX_ICON_SLOTS > slotId)) |
| 133 | { |
| 134 | const size_t JSON_DOC_SIZE = 512U; |
| 135 | DynamicJsonDocument jsonDoc(JSON_DOC_SIZE); |
| 136 | JsonObject jsonCfg = jsonDoc.to<JsonObject>(); |
| 137 | JsonVariantConst jsonFileId = value["fileId"]; |
| 138 | |
| 139 | /* The received configuration may not contain all single key/value pair. |
| 140 | * Therefore read first the complete internal configuration and |
| 141 | * overwrite them with the received ones. |
| 142 | */ |
| 143 | getConfiguration(jsonCfg); |
| 144 | |
| 145 | if (false == jsonFileId.isNull()) |
| 146 | { |
| 147 | jsonCfg["slots"][slotId] = jsonFileId.as<FileMgrService::FileId>(); |
| 148 | isSuccessful = true; |
| 149 | } |
| 150 | |
| 151 | if (true == isSuccessful) |
| 152 | { |
| 153 | JsonObjectConst jsonCfgConst = jsonCfg; |
| 154 | |
| 155 | isSuccessful = setConfiguration(jsonCfgConst); |
| 156 | |
| 157 | if (true == isSuccessful) |
| 158 | { |
| 159 | requestStoreToPersistentMemory(); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | else if (true == topic.equals(TOPIC_SLOTS)) |
| 165 | { |
| 166 | const size_t JSON_DOC_SIZE = 512U; |
| 167 | DynamicJsonDocument jsonDoc(JSON_DOC_SIZE); |
| 168 | JsonObject jsonCfg = jsonDoc.to<JsonObject>(); |
| 169 | JsonVariantConst jsonSlots = value["slots"]; |
| 170 | |
| 171 | /* The received configuration may not contain all single key/value pair. |
| 172 | * Therefore read first the complete internal configuration and |
| 173 | * overwrite them with the received ones. |
| 174 | */ |
| 175 | getConfiguration(jsonCfg); |
| 176 | |
| 177 | /* Note: |
| 178 | * Check only for the key/value pair availability. |
| 179 | * The type check will follow in the setConfiguration(). |
nothing calls this directly
no test coverage detected