| 73 | } |
| 74 | |
| 75 | bool GpsService::startGpsDevice(GpsDeviceRecord& record) { |
| 76 | LOGGER.info("[device {}] starting", record.device->getId()); |
| 77 | |
| 78 | auto lock = mutex.asScopedLock(); |
| 79 | lock.lock(); |
| 80 | |
| 81 | auto device = record.device; |
| 82 | |
| 83 | if (!device->start()) { |
| 84 | LOGGER.error("[device {}] starting failed", record.device->getId()); |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | record.satelliteSubscriptionId = device->subscribeGga([this](hal::Device::Id deviceId, auto& record) { |
| 89 | mutex.lock(); |
| 90 | if (record.fix_quality > 0) { |
| 91 | ggaRecord = record; |
| 92 | ggaTime = kernel::getTicks(); |
| 93 | } |
| 94 | onGgaSentence(deviceId, record); |
| 95 | mutex.unlock(); |
| 96 | }); |
| 97 | |
| 98 | record.rmcSubscriptionId = device->subscribeRmc([this](hal::Device::Id deviceId, auto& record) { |
| 99 | mutex.lock(); |
| 100 | if (record.longitude.value != 0 && record.longitude.scale != 0) { |
| 101 | rmcRecord = record; |
| 102 | rmcTime = kernel::getTicks(); |
| 103 | } |
| 104 | onRmcSentence(deviceId, record); |
| 105 | mutex.unlock(); |
| 106 | }); |
| 107 | |
| 108 | return true; |
| 109 | } |
| 110 | |
| 111 | bool GpsService::stopGpsDevice(GpsDeviceRecord& record) { |
| 112 | LOGGER.info("[device {}] stopping", record.device->getId()); |
nothing calls this directly
no test coverage detected