Compare commits

...

16 Commits

Author SHA1 Message Date
Roberto Viola
89b72c74e0 Update project.pbxproj 2025-03-25 07:13:29 +01:00
Roberto Viola
ae78dd951e Update project.pbxproj 2025-03-25 07:12:46 +01:00
Roberto Viola
0a9a3f9937 Merge branch 'master' into echelon_swift 2025-03-24 17:05:50 +01:00
Roberto Viola
254067d2b7 build fix 2024-11-20 10:12:47 +01:00
Roberto Viola
682f3f612b Update echelonconnectsport.cpp 2024-11-19 20:46:13 +01:00
Roberto Viola
2604031967 Merge branch 'master' into echelon_swift 2024-11-19 20:22:30 +01:00
Roberto Viola
aacb38aee1 Merge branch 'master' into echelon_swift 2024-06-18 10:42:22 +02:00
Roberto Viola
6969bb2680 Merge branch 'master' into echelon_swift 2023-12-23 12:22:24 +01:00
Roberto Viola
e8e17b5338 fixing crash! 2023-12-23 12:22:12 +01:00
Roberto Viola
45f0240c3a Merge branch 'master' into echelon_swift 2023-12-21 15:25:06 +01:00
Roberto Viola
88ee55d4b6 fixing crash? 2023-12-21 15:24:57 +01:00
Roberto Viola
e20ec07926 crash fixed 2023-12-20 07:47:52 +01:00
Roberto Viola
cd56f632da Update echelonconnectsport.cpp 2023-12-19 20:42:28 +01:00
Roberto Viola
b5463efa44 works with the simulator 2023-12-19 19:57:05 +01:00
Roberto Viola
2f41754da9 builds 2023-12-19 19:05:55 +01:00
Roberto Viola
3e82ac83ab starting 2023-12-19 15:59:48 +01:00
8 changed files with 231 additions and 21 deletions

View File

@@ -472,6 +472,7 @@
87BE6FDE272D2A3E00C35795 /* moc_horizongr7bike.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87BE6FDD272D2A3E00C35795 /* moc_horizongr7bike.cpp */; };
87BF116D298E28CA00B5B6E7 /* pelotonbike.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87BF116C298E28CA00B5B6E7 /* pelotonbike.cpp */; };
87BF116F298E28EC00B5B6E7 /* moc_pelotonbike.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87BF116E298E28EC00B5B6E7 /* moc_pelotonbike.cpp */; };
87BFEA2F2CEDDEEE00BDD759 /* ios_echelonconnectsport.mm in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87BFEA2E2CEDDEEE00BDD759 /* ios_echelonconnectsport.mm */; };
87C424262BC1294000503687 /* moc_treadmillErgTable.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87C424252BC1294000503687 /* moc_treadmillErgTable.cpp */; };
87C481FA26DFA7C3006211AD /* eliterizer.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87C481F926DFA7C3006211AD /* eliterizer.cpp */; };
87C481FC26DFA7D1006211AD /* moc_eliterizer.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87C481FB26DFA7D1006211AD /* moc_eliterizer.cpp */; };
@@ -532,6 +533,8 @@
87DAE16926E9FF5000B0527E /* moc_shuaa5treadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DAE16626E9FF5000B0527E /* moc_shuaa5treadmill.cpp */; };
87DAE16A26E9FF5000B0527E /* moc_kingsmithr2treadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DAE16726E9FF5000B0527E /* moc_kingsmithr2treadmill.cpp */; };
87DAE16B26E9FF5000B0527E /* moc_solef80treadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DAE16826E9FF5000B0527E /* moc_solef80treadmill.cpp */; };
87DC27DE2D9280FE007A1B9D /* moxy5sensor.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DC27DD2D9280FE007A1B9D /* moxy5sensor.cpp */; };
87DC27DF2D9280FE007A1B9D /* moc_moxy5sensor.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DC27DB2D9280FE007A1B9D /* moc_moxy5sensor.cpp */; };
87DED80627D1273900BE4FBB /* filedownloader.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DED80427D1273800BE4FBB /* filedownloader.cpp */; };
87DED80827D1274600BE4FBB /* moc_filedownloader.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DED80727D1274500BE4FBB /* moc_filedownloader.cpp */; };
87DF68B825E2673B00FCDA46 /* eslinkertreadmill.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 87DF68B625E2673600FCDA46 /* eslinkertreadmill.cpp */; };
@@ -1469,6 +1472,8 @@
87BF116B298E28CA00B5B6E7 /* pelotonbike.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pelotonbike.h; path = ../src/devices/pelotonbike/pelotonbike.h; sourceTree = "<group>"; };
87BF116C298E28CA00B5B6E7 /* pelotonbike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pelotonbike.cpp; path = ../src/devices/pelotonbike/pelotonbike.cpp; sourceTree = "<group>"; };
87BF116E298E28EC00B5B6E7 /* moc_pelotonbike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_pelotonbike.cpp; sourceTree = "<group>"; };
87BFEA2D2CEDDEEE00BDD759 /* ios_echelonconnectsport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ios_echelonconnectsport.h; path = ../src/ios/ios_echelonconnectsport.h; sourceTree = SOURCE_ROOT; };
87BFEA2E2CEDDEEE00BDD759 /* ios_echelonconnectsport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ios_echelonconnectsport.mm; path = ../src/ios/ios_echelonconnectsport.mm; sourceTree = SOURCE_ROOT; };
87C424252BC1294000503687 /* moc_treadmillErgTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_treadmillErgTable.cpp; sourceTree = "<group>"; };
87C481F826DFA7C3006211AD /* eliterizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = eliterizer.h; path = ../src/devices/eliterizer/eliterizer.h; sourceTree = "<group>"; };
87C481F926DFA7C3006211AD /* eliterizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = eliterizer.cpp; path = ../src/devices/eliterizer/eliterizer.cpp; sourceTree = "<group>"; };
@@ -1559,6 +1564,9 @@
87DAE16626E9FF5000B0527E /* moc_shuaa5treadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_shuaa5treadmill.cpp; sourceTree = "<group>"; };
87DAE16726E9FF5000B0527E /* moc_kingsmithr2treadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_kingsmithr2treadmill.cpp; sourceTree = "<group>"; };
87DAE16826E9FF5000B0527E /* moc_solef80treadmill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_solef80treadmill.cpp; sourceTree = "<group>"; };
87DC27DB2D9280FE007A1B9D /* moc_moxy5sensor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = moc_moxy5sensor.cpp; sourceTree = "<group>"; };
87DC27DC2D9280FE007A1B9D /* moxy5sensor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = moxy5sensor.h; path = ../src/devices/moxy5sensor/moxy5sensor.h; sourceTree = SOURCE_ROOT; };
87DC27DD2D9280FE007A1B9D /* moxy5sensor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moxy5sensor.cpp; path = ../src/devices/moxy5sensor/moxy5sensor.cpp; sourceTree = SOURCE_ROOT; };
87DED80427D1273800BE4FBB /* filedownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = filedownloader.cpp; path = ../src/filedownloader.cpp; sourceTree = "<group>"; };
87DED80527D1273900BE4FBB /* filedownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = filedownloader.h; path = ../src/filedownloader.h; sourceTree = "<group>"; };
87DED80727D1274500BE4FBB /* moc_filedownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = moc_filedownloader.cpp; sourceTree = "<group>"; };
@@ -2179,6 +2187,11 @@
2EB56BE3C2D93CDAB0C52E67 /* Sources */ = {
isa = PBXGroup;
children = (
87DC27DB2D9280FE007A1B9D /* moc_moxy5sensor.cpp */,
87DC27DC2D9280FE007A1B9D /* moxy5sensor.h */,
87DC27DD2D9280FE007A1B9D /* moxy5sensor.cpp */,
87BFEA2D2CEDDEEE00BDD759 /* ios_echelonconnectsport.h */,
87BFEA2E2CEDDEEE00BDD759 /* ios_echelonconnectsport.mm */,
8798FDC02D66075B00CF8EE8 /* osxbluetooth_p.h */,
8798FDC12D66075B00CF8EE8 /* osxbtcentralmanager_p.h */,
8798FDC22D66075B00CF8EE8 /* osxbtgcdtimer_p.h */,
@@ -3707,6 +3720,7 @@
873824BB27E64707004F1B46 /* moc_prober_p.cpp in Compile Sources */,
877758B32C98627300BB1697 /* moc_sportstechelliptical.cpp in Compile Sources */,
8742C2B227C92C30007D3FA0 /* wahookickrsnapbike.cpp in Compile Sources */,
87BFEA2F2CEDDEEE00BDD759 /* ios_echelonconnectsport.mm in Compile Sources */,
87EB918327EE5FE7002535E1 /* moc_inappstore.cpp in Compile Sources */,
87CF516B293C87B000A7CABC /* moc_characteristicwriteprocessore005.cpp in Compile Sources */,
8780D949264FB8B800192D41 /* moc_smartspin2k.cpp in Compile Sources */,
@@ -3845,6 +3859,8 @@
873824B227E64706004F1B46 /* moc_hostname.cpp in Compile Sources */,
873824EB27E647A8004F1B46 /* prober.cpp in Compile Sources */,
875CA9462D0C740000667EE6 /* moc_kineticinroadbike.cpp in Compile Sources */,
87DC27DE2D9280FE007A1B9D /* moxy5sensor.cpp in Compile Sources */,
87DC27DF2D9280FE007A1B9D /* moc_moxy5sensor.cpp in Compile Sources */,
8767EF1E29448D6700810C0F /* characteristicwriteprocessor.cpp in Compile Sources */,
87B617F425F260150094A1CB /* moc_screencapture.cpp in Compile Sources */,
87B617ED25F25FED0094A1CB /* fitshowtreadmill.cpp in Compile Sources */,
@@ -4255,7 +4271,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1037;
CURRENT_PROJECT_VERSION = 1054;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = "ADB_HOST=1";
@@ -4449,7 +4465,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1037;
CURRENT_PROJECT_VERSION = 1054;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
@@ -4679,7 +4695,7 @@
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1037;
CURRENT_PROJECT_VERSION = 1054;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -4775,7 +4791,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1037;
CURRENT_PROJECT_VERSION = 1054;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
@@ -4867,7 +4883,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1037;
CURRENT_PROJECT_VERSION = 1054;
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;
ENABLE_PREVIEWS = YES;
@@ -4983,7 +4999,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1037;
CURRENT_PROJECT_VERSION = 1054;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;

View File

@@ -37,6 +37,7 @@ echelonconnectsport::echelonconnectsport(bool noWriteResistance, bool noHeartSer
void echelonconnectsport::writeCharacteristic(uint8_t *data, uint8_t data_len, const QString &info, bool disable_log,
bool wait_for_response) {
#ifndef Q_OS_IOS
QEventLoop loop;
QTimer timeout;
@@ -60,20 +61,29 @@ void echelonconnectsport::writeCharacteristic(uint8_t *data, uint8_t data_len, c
qDebug() << QStringLiteral("gattWriteCharacteristic is invalid");
return;
}
#endif
if (writeBuffer) {
delete writeBuffer;
}
writeBuffer = new QByteArray((const char *)data, data_len);
#ifdef Q_OS_IOS
#ifndef IO_UNDER_QT
iOS_echelonConnectSport->echelonConnectSport_WriteCharacteristic((unsigned char*)writeBuffer->data(), data_len);
#endif
#else
gattCommunicationChannelService->writeCharacteristic(gattWriteCharacteristic, *writeBuffer);
#endif
if (!disable_log) {
qDebug() << QStringLiteral(" >> ") + writeBuffer->toHex(' ') +
QStringLiteral(" // ") + info;
}
#ifndef Q_OS_IOS
loop.exec();
#endif
}
void echelonconnectsport::forceResistance(resistance_t requestResistance) {
@@ -105,17 +115,23 @@ void echelonconnectsport::sendPoll() {
}
void echelonconnectsport::update() {
#ifndef Q_OS_IOS
if (m_control->state() == QLowEnergyController::UnconnectedState) {
emit disconnected();
return;
}
#endif
if (initRequest) {
initRequest = false;
btinit();
} else if (bluetoothDevice.isValid() && m_control->state() == QLowEnergyController::DiscoveredState &&
} else if (
#ifndef Q_OS_IOS
bluetoothDevice.isValid() && m_control->state() == QLowEnergyController::DiscoveredState &&
gattCommunicationChannelService && gattWriteCharacteristic.isValid() &&
gattNotify1Characteristic.isValid() && gattNotify2Characteristic.isValid() && initDone) {
gattNotify1Characteristic.isValid() && gattNotify2Characteristic.isValid() &&
#endif
initDone) {
update_metrics(true, watts());
// sending poll every 2 seconds
@@ -318,9 +334,11 @@ void echelonconnectsport::characteristicChanged(const QLowEnergyCharacteristic &
qDebug() << QStringLiteral("Last CrankEventTime: ") + QString::number(LastCrankEventTime);
qDebug() << QStringLiteral("Current Watt: ") + QString::number(watts());
#ifndef Q_OS_IOS
if (m_control->error() != QLowEnergyController::NoError) {
qDebug() << QStringLiteral("QLowEnergyController ERROR!!") << m_control->errorString();
}
#endif
}
QTime echelonconnectsport::GetElapsedFromPacket(const QByteArray &packet) {
@@ -366,6 +384,7 @@ void echelonconnectsport::btinit() {
}
void echelonconnectsport::stateChanged(QLowEnergyService::ServiceState state) {
#ifndef Q_OS_IOS
QBluetoothUuid _gattWriteCharacteristicId(QStringLiteral("0bf669f2-45f2-11e7-9598-0800200c9a66"));
QBluetoothUuid _gattNotify1CharacteristicId(QStringLiteral("0bf669f3-45f2-11e7-9598-0800200c9a66"));
QBluetoothUuid _gattNotify2CharacteristicId(QStringLiteral("0bf669f4-45f2-11e7-9598-0800200c9a66"));
@@ -393,7 +412,7 @@ void echelonconnectsport::stateChanged(QLowEnergyService::ServiceState state) {
this, &echelonconnectsport::errorService);
connect(gattCommunicationChannelService, &QLowEnergyService::descriptorWritten, this,
&echelonconnectsport::descriptorWritten);
#endif
// ******************************************* virtual bike init *************************************
if (!firstStateChanged && !this->hasVirtualDevice()
#ifdef Q_OS_IOS
@@ -438,7 +457,7 @@ void echelonconnectsport::stateChanged(QLowEnergyService::ServiceState state) {
}
firstStateChanged = 1;
// ********************************************************************************************************
#ifndef Q_OS_IOS
QByteArray descriptor;
descriptor.append((char)0x01);
descriptor.append((char)0x00);
@@ -447,6 +466,7 @@ void echelonconnectsport::stateChanged(QLowEnergyService::ServiceState state) {
gattCommunicationChannelService->writeDescriptor(
gattNotify2Characteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), descriptor);
}
#endif
}
void echelonconnectsport::descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue) {
@@ -464,7 +484,7 @@ void echelonconnectsport::characteristicWritten(const QLowEnergyCharacteristic &
void echelonconnectsport::serviceScanDone(void) {
qDebug() << QStringLiteral("serviceScanDone");
#ifndef Q_OS_IOS
QBluetoothUuid _gattCommunicationChannelServiceId(QStringLiteral("0bf669f1-45f2-11e7-9598-0800200c9a66"));
gattCommunicationChannelService = m_control->createServiceObject(_gattCommunicationChannelServiceId);
@@ -477,6 +497,7 @@ void echelonconnectsport::serviceScanDone(void) {
homeform::singleton()->setToastRequested("Bluetooth Service Error! Restart the bike!");
m_control->disconnectFromDevice();
}
#endif
}
void echelonconnectsport::errorService(QLowEnergyService::ServiceError err) {
@@ -494,6 +515,14 @@ void echelonconnectsport::error(QLowEnergyController::Error err) {
void echelonconnectsport::deviceDiscovered(const QBluetoothDeviceInfo &device) {
qDebug() << QStringLiteral("Found new device: ") + device.name() + QStringLiteral(" (") +
device.address().toString() + ')';
#ifdef Q_OS_IOS
#ifndef IO_UNDER_QT
iOS_echelonConnectSport = new lockscreen();
iOS_echelonConnectSport->echelonConnectSport(device.name().toStdString().c_str(), this);
return;
#endif
#endif
if (device.name().startsWith(QStringLiteral("ECH"))) {
bluetoothDevice = device;
@@ -531,6 +560,10 @@ void echelonconnectsport::deviceDiscovered(const QBluetoothDeviceInfo &device) {
}
bool echelonconnectsport::connected() {
#ifdef Q_OS_IOS
return true;
#endif
if (!m_control) {
return false;
}
@@ -657,10 +690,16 @@ uint16_t echelonconnectsport::wattsFromResistance(double resistance) {
void echelonconnectsport::controllerStateChanged(QLowEnergyController::ControllerState state) {
qDebug() << QStringLiteral("controllerStateChanged") << state;
if (state == QLowEnergyController::UnconnectedState && m_control) {
if (state == QLowEnergyController::UnconnectedState
#ifndef Q_OS_IOS
&& m_control
#endif
) {
lastResistanceBeforeDisconnection = Resistance.value();
qDebug() << QStringLiteral("trying to connect back again...");
initDone = false;
#ifndef Q_OS_IOS
m_control->connectToDevice();
#endif
}
}

View File

@@ -60,10 +60,12 @@ class echelonconnectsport : public bike {
QTimer *refresh;
#ifndef Q_OS_IOS
QLowEnergyService *gattCommunicationChannelService = nullptr;
QLowEnergyCharacteristic gattWriteCharacteristic;
QLowEnergyCharacteristic gattNotify1Characteristic;
QLowEnergyCharacteristic gattNotify2Characteristic;
#endif
int8_t bikeResistanceOffset = 4;
double bikeResistanceGain = 1.0;
@@ -82,6 +84,7 @@ class echelonconnectsport : public bike {
#ifdef Q_OS_IOS
lockscreen *h = 0;
lockscreen* iOS_echelonConnectSport = nullptr;
#endif
Q_SIGNALS:
@@ -89,14 +92,14 @@ class echelonconnectsport : public bike {
public slots:
void deviceDiscovered(const QBluetoothDeviceInfo &device);
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
void stateChanged(QLowEnergyService::ServiceState state);
void descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue);
void controllerStateChanged(QLowEnergyController::ControllerState state);
private slots:
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
void descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue);
void stateChanged(QLowEnergyService::ServiceState state);
void controllerStateChanged(QLowEnergyController::ControllerState state);
void serviceDiscovered(const QBluetoothUuid &gatt);
void serviceScanDone(void);

View File

@@ -0,0 +1,23 @@
#ifndef IOSECHELONCONNECTSPORT_H
#define IOSECHELONCONNECTSPORT_H
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "echelonconnectsport.h"
@interface ios_echelonconnectsport : NSObject <CBCentralManagerDelegate, CBPeripheralDelegate>
@property (strong, nonatomic) CBCentralManager *centralManager;
@property (strong, nonatomic) CBPeripheral *connectedPeripheral;
@property (strong, nonatomic) NSString *targetDeviceName;
@property echelonconnectsport *qtDevice;
@property (strong, nonatomic) CBCharacteristic *gattWriteCharacteristic;
@property (strong, nonatomic) CBCharacteristic *gattNotify1Characteristic;
@property (strong, nonatomic) CBCharacteristic *gattNotify2Characteristic;
- (instancetype)init:(NSString *)deviceName qtDevice:(void*)qtDevice;
- (void)writeCharacteristc:(uint8_t *)data length:(NSUInteger)length;
@end
#endif // IOSECHELONCONNECTSPORT_H

View File

@@ -0,0 +1,112 @@
#import <CoreBluetooth/CoreBluetooth.h>
#import "ios_echelonconnectsport.h"
@implementation ios_echelonconnectsport
- (instancetype)init:(NSString *)deviceName qtDevice:(void*)qtDevice {
self = [super init];
if (self) {
_targetDeviceName = [deviceName copy];
qDebug() << _targetDeviceName;
_qtDevice = (echelonconnectsport*)qtDevice;
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
return self;
}
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
if (central.state == CBManagerStatePoweredOn) {
qDebug() << "centralManagerDidUpdateState" << central.state;
[self.centralManager scanForPeripheralsWithServices:nil options:nil];
}
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *,id> *)advertisementData RSSI:(NSNumber *)RSSI {
if (peripheral && _targetDeviceName && peripheral.name) {
qDebug() << _targetDeviceName;
if ([peripheral.name isEqualToString:_targetDeviceName]) {
self.connectedPeripheral = peripheral;
[self.centralManager stopScan];
[self.centralManager connectPeripheral:peripheral options:nil];
qDebug() << "didDiscoverPeripheral";
}
}
}
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
peripheral.delegate = self;
[peripheral discoverServices:nil];
}
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
qDebug() << "Peripheral disconnected:" << peripheral << error;
if ([peripheral.name isEqualToString:self.targetDeviceName]) {
_qtDevice->controllerStateChanged(QLowEnergyController::UnconnectedState);
[self.centralManager connectPeripheral:peripheral options:nil];
}
}
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
for (CBService *service in peripheral.services) {
[peripheral discoverCharacteristics:nil forService:service];
}
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
if (characteristic.value) {
qDebug() << "didUpdateValueForCharacteristic" << characteristic;
// Extract the data from characteristic.value and process it as needed
NSData *receivedData = characteristic.value;
NSLog(@"UUID: %@ Received data: %@", characteristic.UUID, receivedData);
// Your processing logic here
//[self.qtDevice characteristicChanged:characteristic.UUID data:receivedData];
QLowEnergyCharacteristic c;
QByteArray b;
const uint8_t* d = (const uint8_t*)[receivedData bytes];
for(int i=0; i<receivedData.length; i++) {
b.append(d[i]);
}
self.qtDevice->characteristicChanged(c, b);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
CBUUID *write = [CBUUID UUIDWithString:@"0bf669f2-45f2-11e7-9598-0800200c9a66"];
CBUUID *uuid1 = [CBUUID UUIDWithString:@"0bf669f3-45f2-11e7-9598-0800200c9a66"];
CBUUID *uuid2 = [CBUUID UUIDWithString:@"0bf669f4-45f2-11e7-9598-0800200c9a66"];
for (CBCharacteristic *characteristic in service.characteristics) {
if ([characteristic.UUID isEqual:uuid1]) {
self.gattNotify1Characteristic = characteristic;
[peripheral setNotifyValue:YES forCharacteristic:self.gattNotify1Characteristic];
} else if ([characteristic.UUID isEqual:uuid2]) {
self.gattNotify2Characteristic = characteristic;
[peripheral setNotifyValue:YES forCharacteristic:self.gattNotify2Characteristic];
} else if ([characteristic.UUID isEqual:write]) {
self.gattWriteCharacteristic = characteristic;
}
}
// Verifica se entrambe le caratteristiche sono state trovate
if (self.gattNotify1Characteristic && self.gattNotify2Characteristic && self.gattWriteCharacteristic) {
self.qtDevice->stateChanged(QLowEnergyService::ServiceDiscovered);
self.qtDevice->descriptorWritten(QLowEnergyDescriptor(), QByteArray());
}
}
- (void)writeCharacteristc:(uint8_t *)data length:(NSUInteger)length {
if (self.connectedPeripheral.state != CBPeripheralStateConnected) {
qDebug() << "Cannot send. Peripheral is not connected.";
return;
}
NSData *dataToSend = [NSData dataWithBytes:data length:length];
qDebug() << "writeCharacteristc" << dataToSend;
if (self.gattWriteCharacteristic) {
[self.connectedPeripheral writeValue:dataToSend forCharacteristic:self.gattWriteCharacteristic type:CBCharacteristicWriteWithResponse];
}
}
@end

View File

@@ -73,6 +73,10 @@ class lockscreen {
// Elite Aria Fan
void eliteAriaFan();
void eliteAriaFan_fanSpeedRequest(unsigned char speed);
// Echelon Connect Sport
void echelonConnectSport(const char* Name, void* deviceClass);
void echelonConnectSport_WriteCharacteristic(unsigned char* qdata, unsigned char length);
// Zwift API
void zwift_api_decodemessage_player(const char* data, int len);

View File

@@ -10,17 +10,18 @@
#include <QDebug>
#include "ios/AdbClient.h"
#include "ios/ios_eliteariafan.h"
#include "ios/ios_echelonconnectsport.h"
@class virtualbike_ios_swift;
@class virtualbike_zwift;
@class virtualrower;
@class virtualrower_zwift;
@class virtualtreadmill_zwift;
@class healthkit;
static healthkit* h = 0;
static virtualbike_ios_swift* _virtualbike = nil;
static virtualbike_zwift* _virtualbike_zwift = nil;
static virtualrower* _virtualrower = nil;
static virtualrower_zwift* _virtualrower = nil;
static virtualtreadmill_zwift* _virtualtreadmill_zwift = nil;
static GarminConnect* Garmin = 0;
@@ -28,6 +29,7 @@ static GarminConnect* Garmin = 0;
static AdbClient *_adb = 0;
static ios_eliteariafan* ios_eliteAriaFan = nil;
static ios_echelonconnectsport* ios_echelonConnectSport = nil;
static zwift_protobuf_layer* zwiftProtobufLayer = nil;
@@ -113,7 +115,7 @@ void lockscreen::virtualbike_zwift_ios(bool disable_hr, bool garmin_bluetooth_co
void lockscreen::virtualrower_ios()
{
_virtualrower = [[virtualrower alloc] init];
_virtualrower = [[virtualrower_zwift alloc] init];
}
double lockscreen::virtualbike_getCurrentSlope()
@@ -326,6 +328,17 @@ void lockscreen::eliteAriaFan_fanSpeedRequest(unsigned char speed) {
}
}
void lockscreen::echelonConnectSport(const char* Name, void* deviceClass) {
NSString *deviceName = [NSString stringWithCString:Name encoding:NSASCIIStringEncoding];
ios_echelonConnectSport = [[ios_echelonconnectsport alloc] init:deviceName qtDevice:deviceClass];
}
void lockscreen::echelonConnectSport_WriteCharacteristic(unsigned char* qdata, unsigned char length) {
if(ios_echelonConnectSport) {
[ios_echelonConnectSport writeCharacteristc:qdata length:length ];
}
}
void lockscreen::zwift_api_decodemessage_player(const char* data, int len) {
NSData *d = [NSData dataWithBytes:data length:len];
[zwiftProtobufLayer getPlayerStateWithValue:d];

View File

@@ -2,7 +2,7 @@ import CoreBluetooth
let rowerUuid = CBUUID(string: "0x2AD1");
@objc public class virtualrower: NSObject {
@objc public class virtualrower_zwift: NSObject {
private var peripheralManager: rowerBLEPeripheralManagerZwift!
@objc public override init() {