Mercurial > public > ostc_companion
comparison OSTCSportOperations.cpp @ 1:0b3630a29ad8
Initial version based on previous repository.
Project was ported to QT6 and in now cmake based.
| author | Ideenmodellierer <tiefenrauscher@web.de> |
|---|---|
| date | Thu, 27 Nov 2025 18:40:28 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:76ccd6ce50c0 | 1:0b3630a29ad8 |
|---|---|
| 1 ////////////////////////////////////////////////////////////////////////////// | |
| 2 /// \file OSTCSportOperations.cpp | |
| 3 /// \brief Implementing various operations for OSTC3 dive computer | |
| 4 /// \author JD Gascuel. | |
| 5 /// | |
| 6 /// \copyright (c) 2011-2016 JD Gascuel. All rights reserved. | |
| 7 /// $Id$ | |
| 8 ////////////////////////////////////////////////////////////////////////////// | |
| 9 // | |
| 10 // BSD 2-Clause License: | |
| 11 // | |
| 12 // Redistribution and use in source and binary forms, with or without | |
| 13 // modification, are permitted provided that the following conditions | |
| 14 // are met: | |
| 15 // | |
| 16 // 1. Redistributions of source code must retain the above copyright notice, | |
| 17 // this list of conditions and the following disclaimer. | |
| 18 // | |
| 19 // 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 20 // this list of conditions and the following disclaimer in the documentation | |
| 21 // and/or other materials provided with the distribution. | |
| 22 // | |
| 23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 24 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 25 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 26 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
| 27 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 28 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 29 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 30 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 31 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 32 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 33 // THE POSSIBILITY OF SUCH DAMAGE. | |
| 34 // | |
| 35 ////////////////////////////////////////////////////////////////////////////// | |
| 36 | |
| 37 #include "OSTCSportOperations.h" | |
| 38 | |
| 39 #include "Utils/Log.h" | |
| 40 | |
| 41 #include <QStringList> | |
| 42 #include <QRegularExpression> | |
| 43 | |
| 44 ////////////////////////////////////////////////////////////////////////////// | |
| 45 | |
| 46 OSTCSportOperations::OSTCSportOperations() | |
| 47 { | |
| 48 emulatorName = "OSTC_Sport"; | |
| 49 } | |
| 50 | |
| 51 ////////////////////////////////////////////////////////////////////////////// | |
| 52 #if 0 | |
| 53 QRegExp OSTCSportOperations::portTemplate() const | |
| 54 { | |
| 55 #if defined(Q_OS_MAC) | |
| 56 return QRegExp("tty.OSTCs.*", Qt::CaseInsensitive); | |
| 57 #elif defined(Q_OS_LINUX) | |
| 58 // Seems ok for debian, ubuntu, and SUSE (google dixit). | |
| 59 // Obviously, needs the rfcomm package. "hcitool scan" or lsusb to have | |
| 60 // a list of connected stuff... | |
| 61 return QRegExp("rfcomm.*", Qt::CaseInsensitive); | |
| 62 #elif defined(Q_OS_WIN) | |
| 63 return QRegExp("COM.*", Qt::CaseSensitive); | |
| 64 #endif | |
| 65 } | |
| 66 #endif | |
| 67 QRegularExpression OSTCSportOperations::portTemplate() const | |
| 68 { | |
| 69 #if defined(Q_OS_MAC) | |
| 70 return QRegularExpression("tty.OSTCs.*", | |
| 71 QRegularExpression::CaseInsensitiveOption); | |
| 72 #elif defined(Q_OS_LINUX) | |
| 73 // Debian, Ubuntu, SUSE, benötigt rfcomm-Paket | |
| 74 return QRegularExpression("rfcomm.*", | |
| 75 QRegularExpression::CaseInsensitiveOption); | |
| 76 #elif defined(Q_OS_WIN) | |
| 77 return QRegularExpression("COM.*"); // default: case-sensitive | |
| 78 #endif | |
| 79 } | |
| 80 ////////////////////////////////////////////////////////////////////////////// | |
| 81 | |
| 82 void OSTCSportOperations::getIdentity() | |
| 83 { | |
| 84 descriptionString.clear(); | |
| 85 | |
| 86 LOG_TRACE("Getting model..."); | |
| 87 HardwareDescriptor hw = hardwareDescriptor(); | |
| 88 if( hw != HW_UNKNOWN_OSTC && hw != HW_OSTCSport_a && hw != HW_OSTCSport_b ) | |
| 89 LOG_THROW( "Not an OSTC Sport." ); | |
| 90 | |
| 91 LOG_TRACE("Getting identity..."); | |
| 92 getCommonIdentity(); | |
| 93 | |
| 94 // OTC Sport fw is between 10.00 and 19.99 (coded 100x Hi + Lo) | |
| 95 // and serial is between 10.000 and 19.999 | |
| 96 if( hw == HW_UNKNOWN_OSTC | |
| 97 && ( firmware() < 1000 || firmware() > 1999 | |
| 98 || serialNumber() < 10000 || serialNumber() > 20000) ) | |
| 99 LOG_THROW( "Not an OSTC Sport (fw " | |
| 100 << (firmware()/100) << "." << QString::asprintf("%02d", firmware()%100) << ", #" | |
| 101 << serialNumber() << ")."); | |
| 102 hw = HW_OSTCSport_a; | |
| 103 | |
| 104 LOG_TRACE("Found " << descriptionString); | |
| 105 } | |
| 106 | |
| 107 ////////////////////////////////////////////////////////////////////////////// | |
| 108 | |
| 109 QStringList OSTCSportOperations::listPorts() const | |
| 110 { | |
| 111 return listBluetoothPorts(); | |
| 112 } | |
| 113 | |
| 114 ////////////////////////////////////////////////////////////////////////////// | |
| 115 | |
| 116 QString OSTCSportOperations::firmwareTemplate() const | |
| 117 { | |
| 118 return "*_ostc_sport_firmware.hex"; | |
| 119 } | |
| 120 | |
| 121 QSize OSTCSportOperations::nameSize() const | |
| 122 { | |
| 123 return QSize(12, 5); | |
| 124 } | |
| 125 | |
| 126 QString OSTCSportOperations::model() const | |
| 127 { | |
| 128 return "OSTCSport"; | |
| 129 } | |
| 130 | |
| 131 HardwareOperations::CompanionFeatures OSTCSportOperations::supported() const | |
| 132 { | |
| 133 // No ICON, no DUMPSCREEN, no HELIUM, no CCR | |
| 134 return CompanionFeatures(PARAMETERS|DATE|NAME|FIRMWARE | |
| 135 |BLUETOOTH); | |
| 136 } |
