diff --git a/SenzorDataCollectorApp.xcodeproj/project.pbxproj b/SenzorDataCollectorApp.xcodeproj/project.pbxproj index 19fcfcb70a12606a1692ce498726659eaa82ab2e..83fc2645bd86813415bf4462ded5e4bd0f85d000 100644 --- a/SenzorDataCollectorApp.xcodeproj/project.pbxproj +++ b/SenzorDataCollectorApp.xcodeproj/project.pbxproj @@ -489,7 +489,7 @@ INFOPLIST_KEY_NSFileProviderPresenceUsageDescription = "The app needs it to save files"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "The needs ot use senzor data"; - INFOPLIST_KEY_NSMotionUsageDescription = "THe app need is"; + INFOPLIST_KEY_NSMotionUsageDescription = "App mesasures sensors"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -501,7 +501,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = hu.itk.ppke.SenzorDataCollectorApp; + PRODUCT_BUNDLE_IDENTIFIER = "hu.itk.ppke.SenzorDataCollectorApp-"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -527,7 +527,7 @@ INFOPLIST_KEY_NSFileProviderPresenceUsageDescription = "The app needs it to save files"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "The needs ot use senzor data"; - INFOPLIST_KEY_NSMotionUsageDescription = "THe app need is"; + INFOPLIST_KEY_NSMotionUsageDescription = "App mesasures sensors"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -539,7 +539,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = hu.itk.ppke.SenzorDataCollectorApp; + PRODUCT_BUNDLE_IDENTIFIER = "hu.itk.ppke.SenzorDataCollectorApp-"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; diff --git a/SenzorDataCollectorApp/Info.plist b/SenzorDataCollectorApp/Info.plist index dd703eebf4c484566e67def28ed2ff8195b44644..57a546a1b27cb6fb92477a6cc095795a6dcba095 100644 --- a/SenzorDataCollectorApp/Info.plist +++ b/SenzorDataCollectorApp/Info.plist @@ -2,8 +2,6 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>NSMotionUsageDescription</key> - <string>App mesasures sensors</string> <key>BGTaskSchedulerPermittedIdentifiers</key> <array> <string>hu.itk.ppke.backgroundTask</string> @@ -14,5 +12,7 @@ <string>processing</string> <string>remote-notification</string> </array> + <key>NSLocalNetworkUsageDescription</key> + <string></string> </dict> </plist> diff --git a/SenzorDataCollectorApp/Sensors.swift b/SenzorDataCollectorApp/Sensors.swift index 5cf4ec758f3e94c29d074859dcdb729315522d1f..7031147a39780d640c3535caa6908282fbba522f 100644 --- a/SenzorDataCollectorApp/Sensors.swift +++ b/SenzorDataCollectorApp/Sensors.swift @@ -31,9 +31,9 @@ struct MeasuringSensors: Hashable, Identifiable{ enum Sensors: String, CaseIterable { case acc = "Accelerometer" case gyro = "Gyroscope" - case alt = "Altimeter" +// case alt = "Altimeter" case mag = "Magnetometer" - case light = "Light Sensor" +// case light = "Light Sensor" } @@ -46,7 +46,7 @@ class SensorCollector: ObservableObject { let gyroDataQueue = OperationQueue() let magDataQueue = OperationQueue() let altDataQueue = OperationQueue() - let lightDataQueue = OperationQueue() +// let lightDataQueue = OperationQueue() var sensorDataQueues: [OperationQueue] init(activeSensorList: [MeasuringSensors]) { @@ -73,7 +73,7 @@ class SensorCollector: ObservableObject { accStartRecording(motionManager: motionManager) gyroStartRecording(motionManager: motionManager) magStartRecording(motionManager: motionManager) - altStartRecording(altimeter: altimeter) +// altStartRecording(altimeter: altimeter) } @@ -81,7 +81,7 @@ class SensorCollector: ObservableObject { motionManager.stopAccelerometerUpdates() motionManager.stopGyroUpdates() motionManager.stopMagnetometerUpdates() - altimeter.stopRelativeAltitudeUpdates() +// altimeter.stopRelativeAltitudeUpdates() print("Sensors stopped all recording") for index in 0..<activeSensorsList.count { activeSensorsList[index].isSensorActive = false @@ -90,33 +90,34 @@ class SensorCollector: ObservableObject { // ------------------------------------------- A L T I T U D E ------------------------------------------- - func altStartRecording(altimeter: CMAltimeter) { - if CMAltimeter.isRelativeAltitudeAvailable() { - - for index in 0..<activeSensorsList.count { - if activeSensorsList[index].sensorName == Sensors.alt.rawValue { - activeSensorsList[index].isSensorActive = true - } - } - altimeter.startRelativeAltitudeUpdates(to: altDataQueue) { (altimeterData, error) in - if let altimeterData = altimeterData { - let pressure = altimeterData.pressure.doubleValue - let rel_altitude = altimeterData.relativeAltitude.doubleValue - let altTimestampedTuple = (Int(Date().timeIntervalSince1970 * 1000), (x: rel_altitude, y: pressure, z: 0.0)) - - DispatchQueue.main.async { - if let index = self.activeSensorsList.firstIndex(where: { $0.sensorName == Sensors.alt.rawValue }) { - self.activeSensorsList[index].sensorData.append(altTimestampedTuple) - } - } - } else { - print("Altitude data not available or there was an error: \(error?.localizedDescription ?? "Unknown error")") - } - } - } else { - print("Altimeter not available on this device.") - } - } +// func altStartRecording(altimeter: CMAltimeter) { +// if CMAltimeter.isRelativeAltitudeAvailable() { +// +// for index in 0..<activeSensorsList.count { +// if activeSensorsList[index].sensorName == Sensors.alt.rawValue { +// activeSensorsList[index].isSensorActive = true +// } +// } +// +// altimeter.startRelativeAltitudeUpdates(to: altDataQueue) { (altimeterData, error) in +// if let altimeterData = altimeterData { +// let pressure = altimeterData.pressure.doubleValue +// let rel_altitude = altimeterData.relativeAltitude.doubleValue +// let altTimestampedTuple = (Int(Date().timeIntervalSince1970 * 1000), (x: rel_altitude, y: pressure, z: 0.0)) +// +// DispatchQueue.main.async { +// if let index = self.activeSensorsList.firstIndex(where: { $0.sensorName == Sensors.alt.rawValue }) { +// self.activeSensorsList[index].sensorData.append(altTimestampedTuple) +// } +// } +// } else { +// print("Altitude data not available or there was an error: \(error?.localizedDescription ?? "Unknown error")") +// } +// } +// } else { +// print("Altimeter not available on this device.") +// } +// } diff --git a/SenzorDataCollectorApp/StartingView.swift b/SenzorDataCollectorApp/StartingView.swift index 6b0ab955ccd874c1560269e16ae19c1e1c731c27..804530ddd0d0e86f031637d089983df5c8401928 100644 --- a/SenzorDataCollectorApp/StartingView.swift +++ b/SenzorDataCollectorApp/StartingView.swift @@ -3,10 +3,6 @@ // sensorDataCollectorApp // // Created by Miklósi Máté on 20/01/2024. -// - -//TODO -// - start - stop debugging import Foundation import SwiftUI @@ -17,6 +13,7 @@ import UniformTypeIdentifiers import MobileCoreServices import SensorKit import Combine +import Network struct StartingView: View { //----------SERVER CONNECTION SETTINGS AND VARS ----------------------------------------------- @@ -46,7 +43,7 @@ struct StartingView: View { @State var fileLocations: [URL] = [] let activityManager = CMMotionActivityManager() - + @State private var wifiName: String = "Not Available" @State var debug = true var body: some View { @@ -71,11 +68,11 @@ struct StartingView: View { customTimer.startTimer() }.padding().disabled(manager.state != "Ready").opacity(debug ? 0 : 1) - Button("STOP Iterations") { - customTimer.stopTimer() - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) - - }.padding().opacity(debug ? 0 : 1) +// Button("STOP Iterations") { +// customTimer.stopTimer() +// sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) +// +// }.padding().opacity(debug ? 0 : 1) Text("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= 0 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised")") .padding() @@ -94,7 +91,7 @@ struct StartingView: View { label: { Text("Details") } ) } - } + }.opacity(debug ? 0 : 1) Button("CreateDIR"){ createDirectory() }.padding().opacity(debug ? 0 : 1) @@ -207,10 +204,20 @@ struct StartingView: View { ) .foregroundColor(.white) } - // TODO - does not reflect correctly + // Text(manager.serverResponse == "Basic response" || manager.serverResponse == "OK" ? "" : manager.serverResponse) Text(manager.state != "Ready" ? "Click the button to connect to the server " : "Click the button to start the measurements") + Text("Status: \(manager.state)").padding().opacity(manager.state == "Ready" ? 0 : 1) + HStack{ + TextField("Enter Host", text: $manager.hostName) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .padding(.vertical) + Text(":") + TextField("Enter Port Number", text: $manager.portNumber) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .padding(.vertical) + }.padding().opacity(manager.state == "Ready" ? 0 : 1) }) //----------------------------- TIMER REFRESH --------------------------------- .onReceive(timer){ _ in