| 123 | } |
| 124 | |
| 125 | bool GpsDevice::start() { |
| 126 | auto lock = mutex.asScopedLock(); |
| 127 | lock.lock(); |
| 128 | |
| 129 | if (thread != nullptr && thread->getState() != Thread::State::Stopped) { |
| 130 | LOGGER.warn("Already started"); |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | threadInterrupted = false; |
| 135 | |
| 136 | LOGGER.info("Starting thread"); |
| 137 | setState(State::PendingOn); |
| 138 | |
| 139 | thread = std::make_unique<Thread>( |
| 140 | "gps", |
| 141 | 4096, |
| 142 | [this]() { |
| 143 | return this->threadMain(); |
| 144 | } |
| 145 | ); |
| 146 | thread->setPriority(tt::Thread::Priority::High); |
| 147 | thread->start(); |
| 148 | |
| 149 | LOGGER.info("Starting finished"); |
| 150 | return true; |
| 151 | } |
| 152 | |
| 153 | bool GpsDevice::stop() { |
| 154 | auto lock = mutex.asScopedLock(); |