| 74 | *****************************************************************************/ |
| 75 | |
| 76 | bool TimerService::start() |
| 77 | { |
| 78 | bool isSuccessful = true; |
| 79 | |
| 80 | /* Is service already running? */ |
| 81 | if (true == m_isRunning) |
| 82 | { |
| 83 | /* Nothing to do. */ |
| 84 | ; |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | SettingsService& settings = SettingsService::getInstance(); |
| 89 | TopicHandlerService& topicHandlerService = TopicHandlerService::getInstance(); |
| 90 | JsonObjectConst jsonExtra; /* Empty */ |
| 91 | ITopicHandler::GetTopicFunc getTopicFunc = |
| 92 | [this](const String& topic, JsonObject& jsonValue) -> bool { |
| 93 | return this->getTopic(topic, jsonValue); |
| 94 | }; |
| 95 | TopicHandlerService::HasChangedFunc hasChangedFunc = |
| 96 | [this](const String& topic) -> bool { |
| 97 | return this->hasTopicChanged(topic); |
| 98 | }; |
| 99 | ITopicHandler::SetTopicFunc setTopicFunc = |
| 100 | [this](const String& topic, const JsonObjectConst& jsonValue) -> bool { |
| 101 | return this->setTopic(topic, jsonValue); |
| 102 | }; |
| 103 | |
| 104 | if (false == m_mutex.create()) |
| 105 | { |
| 106 | isSuccessful = false; |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | if (false == settings.open(true)) |
| 111 | { |
| 112 | m_deviceId = settings.getHostname().getDefault(); |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | m_deviceId = settings.getHostname().getValue(); |
| 117 | |
| 118 | settings.close(); |
| 119 | } |
| 120 | |
| 121 | if (false == loadSettings()) |
| 122 | { |
| 123 | saveSettings(); |
| 124 | } |
| 125 | |
| 126 | topicHandlerService.registerTopic(m_deviceId, ENTITY_ID, TOPIC, jsonExtra, getTopicFunc, hasChangedFunc, setTopicFunc, nullptr); |
| 127 | |
| 128 | m_processTimer.start(PROCESS_PERIOD); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | if (false == isSuccessful) |
| 133 | { |
nothing calls this directly
no test coverage detected