Skip to content
Snippets Groups Projects
Commit 72b9c3b2 authored by Miklosimate's avatar Miklosimate
Browse files

Startup fix

parent ce76d638
Branches
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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>
......@@ -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.")
// }
// }
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment