mirror of
https://github.com/cagnulein/qdomyos-zwift.git
synced 2026-02-18 00:17:41 +01:00
Compare commits
3 Commits
2.20.12
...
dirconswif
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e779dac47 | ||
|
|
8c96866153 | ||
|
|
8f3ee11708 |
@@ -228,6 +228,7 @@
|
||||
873824EE27E647A9004F1B46 /* service.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873824D827E647A6004F1B46 /* service.cpp */; };
|
||||
873824EF27E647A9004F1B46 /* query.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873824DA27E647A7004F1B46 /* query.cpp */; };
|
||||
873824F027E647A9004F1B46 /* server.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873824DF27E647A8004F1B46 /* server.cpp */; };
|
||||
873A1692290C3FAA00300DFA /* Dircon.swift in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873A1691290C3FAA00300DFA /* Dircon.swift */; };
|
||||
873CD20727EF8D8A000131BC /* inappproduct.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873CD20227EF8D89000131BC /* inappproduct.cpp */; };
|
||||
873CD20827EF8D8A000131BC /* inappstore.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873CD20327EF8D89000131BC /* inappstore.cpp */; };
|
||||
873CD20927EF8D8A000131BC /* inapppurchasebackend.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 873CD20427EF8D8A000131BC /* inapppurchasebackend.cpp */; };
|
||||
@@ -936,6 +937,7 @@
|
||||
873824DF27E647A8004F1B46 /* server.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = server.cpp; path = ../src/qmdnsengine/src/src/server.cpp; sourceTree = "<group>"; };
|
||||
873824E027E647A8004F1B46 /* hostname_p.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hostname_p.h; path = ../src/qmdnsengine/src/src/hostname_p.h; sourceTree = "<group>"; };
|
||||
873824E127E647A8004F1B46 /* browser_p.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = browser_p.h; path = ../src/qmdnsengine/src/src/browser_p.h; sourceTree = "<group>"; };
|
||||
873A1691290C3FAA00300DFA /* Dircon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Dircon.swift; path = ../src/ios/Dircon.swift; sourceTree = "<group>"; };
|
||||
873CD20227EF8D89000131BC /* inappproduct.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = inappproduct.cpp; path = ../src/purchasing/inapp/inappproduct.cpp; sourceTree = "<group>"; };
|
||||
873CD20327EF8D89000131BC /* inappstore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = inappstore.cpp; path = ../src/purchasing/inapp/inappstore.cpp; sourceTree = "<group>"; };
|
||||
873CD20427EF8D8A000131BC /* inapppurchasebackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = inapppurchasebackend.cpp; path = ../src/purchasing/inapp/inapppurchasebackend.cpp; sourceTree = "<group>"; };
|
||||
@@ -2123,6 +2125,7 @@
|
||||
68418A2D51B69FC30BF5A41C /* virtualbike.h */,
|
||||
35E903698E72424585D33829 /* virtualtreadmill.h */,
|
||||
C8CE72E7B224D8B886614E3F /* domyosbike.h */,
|
||||
873A1691290C3FAA00300DFA /* Dircon.swift */,
|
||||
);
|
||||
name = Sources;
|
||||
sourceTree = "<group>";
|
||||
@@ -3096,6 +3099,7 @@
|
||||
7DEEAF0C3D671FBFD84ACFCE /* moc_homeform.cpp in Compile Sources */,
|
||||
934A3E33459C9220F257B271 /* moc_qfit.cpp in Compile Sources */,
|
||||
873F0231274BE47D002D0349 /* moc_mcfbike.cpp in Compile Sources */,
|
||||
873A1692290C3FAA00300DFA /* Dircon.swift in Compile Sources */,
|
||||
8718CBAE263063CE004BF4EE /* moc_soleelliptical.cpp in Compile Sources */,
|
||||
8738248227E646C4004F1B46 /* dirconprocessor.cpp in Compile Sources */,
|
||||
87EFE45927A518F5006EA1C3 /* nautiluselliptical.cpp in Compile Sources */,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "dirconprocessor.h"
|
||||
#include "dirconpacket.h"
|
||||
#include "qzsettings.h"
|
||||
#include "ios/lockscreen.h"
|
||||
#include <QSettings>
|
||||
|
||||
DirconProcessor::DirconProcessor(const QList<DirconProcessorService *> &my_services, const QString &serv_name,
|
||||
@@ -42,6 +43,7 @@ void DirconProcessor::initAdvertising() {
|
||||
connect(zeroConf, SIGNAL(servicePublished()), this, SLOT(advOK()));
|
||||
connect(zeroConf, SIGNAL(error(QZeroConf::error_t)), this, SLOT(advError(QZeroConf::error_t)));
|
||||
}*/
|
||||
|
||||
if (!mdnsServer) {
|
||||
qDebug() << "Dircon Adv init for" << serverName;
|
||||
mdnsServer = new QMdnsEngine::Server(this);
|
||||
@@ -60,8 +62,18 @@ void DirconProcessor::initAdvertising() {
|
||||
((i++ < services.size() - 1) ? QStringLiteral(",") : QStringLiteral(""));
|
||||
mdnsService.addAttribute(QByteArrayLiteral("ble-service-uuids"), ble_uuids.toUtf8());
|
||||
mdnsService.setPort(serverPort);
|
||||
mdnsProvider->update(mdnsService);
|
||||
qDebug() << "Dircon Adv init for" << serverName << " end";
|
||||
#ifdef Q_OS_IOS
|
||||
#ifndef IO_UNDER_QT
|
||||
lockscreen h;
|
||||
if(h.dircon(reinterpret_cast<const unsigned char*>(serverName.toUtf8().constData()), serverName.toUtf8().length(), serverPort, reinterpret_cast<const unsigned char*>(mac.toUtf8().constData()), mac.toUtf8().length(), reinterpret_cast<const unsigned char*>(serialN.toUtf8().constData()), serialN.toUtf8().length(), reinterpret_cast<const unsigned char*>(ble_uuids.toUtf8().constData()), ble_uuids.toUtf8().length())) {
|
||||
mdnsServer = (QMdnsEngine::Server*)1; // fake
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
mdnsProvider->update(mdnsService);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ var pedometer = CMPedometer()
|
||||
|
||||
@objc public class healthkit:NSObject {
|
||||
let w = watchAppStart()
|
||||
var dirconServer: [Dircon] = []
|
||||
|
||||
@objc public func request()
|
||||
{
|
||||
@@ -28,6 +29,7 @@ var pedometer = CMPedometer()
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateHeartRate), userInfo: nil, repeats: true)
|
||||
}
|
||||
|
||||
Server.server?.start()
|
||||
|
||||
LocalNotificationHelper.requestPermission()
|
||||
@@ -44,6 +46,16 @@ var pedometer = CMPedometer()
|
||||
//w.startWatchApp()
|
||||
}
|
||||
|
||||
@objc public func dircon(name: String, port: UInt16, macAddress: String, serialNumber: String, bleServiceUuids: String) -> Bool {
|
||||
do {
|
||||
dirconServer.append(try Dircon(name: name, port: port, macAddress: macAddress, serialNumber: serialNumber, bleServiceUuids: bleServiceUuids))
|
||||
return dirconServer.last!.start()
|
||||
} catch {
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@objc public func heartRate() -> Int
|
||||
{
|
||||
return WatchKitConnection.currentHeartRate;
|
||||
|
||||
50
src/ios/Dircon.swift
Normal file
50
src/ios/Dircon.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// Dircon.swift
|
||||
// qdomyoszwift
|
||||
//
|
||||
// Created by Roberto Viola on 28/10/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Network
|
||||
import UIKit
|
||||
|
||||
class Dircon {
|
||||
|
||||
let listener: NWListener
|
||||
var connections: [Connection] = []
|
||||
|
||||
init(name: String, port: UInt16, macAddress: String, serialNumber: String, bleServiceUuids: String) throws {
|
||||
let o = NWProtocolUDP.Options()
|
||||
let parameters = NWParameters(dtls: nil, udp: o)
|
||||
parameters.includePeerToPeer = true
|
||||
//parameters.requiredLocalEndpoint = NWEndpoint.hostPort(host: NWEndpoint.Host(name + "H"), port: NWEndpoint.Port(rawValue: port)!)
|
||||
parameters.allowFastOpen = true
|
||||
parameters.acceptLocalOnly = true
|
||||
listener = try NWListener(using: parameters, on: NWEndpoint.Port(rawValue: port)!)
|
||||
let records = ["mac-address": macAddress, "serial-number": serialNumber, "ble-service-uuids" : bleServiceUuids]
|
||||
if #available(iOS 13.0, *) {
|
||||
listener.service = NWListener.Service(name: name, type: "_wahoo-fitness-tnp._tcp", domain: "local", txtRecord: NWTXTRecord(records))
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
}
|
||||
|
||||
func start() -> Bool {
|
||||
if(listener.service == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
listener.stateUpdateHandler = { newState in
|
||||
print("listener.stateUpdateHandler \(newState)")
|
||||
}
|
||||
listener.newConnectionHandler = { [weak self] newConnection in
|
||||
print("listener.newConnectionHandler \(newConnection)")
|
||||
let connection = Connection(connection: newConnection)
|
||||
self?.connections += [connection]
|
||||
}
|
||||
listener.start(queue: .main)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ class lockscreen {
|
||||
void request();
|
||||
long heartRate();
|
||||
long stepCadence();
|
||||
bool dircon(const unsigned char* name, int nameLen, int port, const unsigned char* macAddress, int macAddressLen, const unsigned char* serialNumber, int serialNumberLen, const unsigned char* bleServiceUuids, int bleServiceUuidsLen);
|
||||
void setKcal(double kcal);
|
||||
void setDistance(double distance);
|
||||
|
||||
|
||||
@@ -39,6 +39,15 @@ long lockscreen::stepCadence()
|
||||
return [h stepCadence];
|
||||
}
|
||||
|
||||
bool lockscreen::dircon(const unsigned char* name, int nameLen, int port, const unsigned char* macAddress, int macAddressLen, const unsigned char* serialNumber, int serialNumberLen, const unsigned char* bleServiceUuids, int bleServiceUuidsLen)
|
||||
{
|
||||
NSString* Name = [[NSString alloc] initWithBytes:name length:nameLen encoding:NSUTF8StringEncoding];
|
||||
NSString* MacAddress = [[NSString alloc] initWithBytes:macAddress length:macAddressLen encoding:NSUTF8StringEncoding];
|
||||
NSString* SerialNumber = [[NSString alloc] initWithBytes:serialNumber length:serialNumberLen encoding:NSUTF8StringEncoding];
|
||||
NSString* BleServiceUuids = [[NSString alloc] initWithBytes:bleServiceUuids length:bleServiceUuidsLen encoding:NSUTF8StringEncoding];
|
||||
return [h dirconWithName:Name port:port macAddress:MacAddress serialNumber:SerialNumber bleServiceUuids:BleServiceUuids];
|
||||
}
|
||||
|
||||
void lockscreen::setKcal(double kcal)
|
||||
{
|
||||
[h setKcalWithKcal:kcal];
|
||||
|
||||
Reference in New Issue
Block a user