I read device core motion data for accelerator, gyroscope, attitude, magnetic field values on an interval on Apple Watch. For processing the data, I need to know the data range for every data that is maximum and minimum value of the data.
I couldn't find the data range for accelerator, gyroscope, etc. Help me to find out the data range to process the received data.
Post
Replies
Boosts
Views
Activity
I am trying to send file from watch to iOS every 15min. Core motion data will be saved in a file in watch and every 15 min watch sends it to iOS. both watch and iOS app are in background. So,I activate iOS app by calling sendMessage and on replyHandler, calling transferFile to send the file to iOS. If watch is in foreground its working fine, when watch in background, send message is received by iOS but transferFile is not working. only when watch app comes to foreground, it sends the file to iOS.
Code on watch side
func transferMotionDataFile() {
self.accessQueue.async {
sendFileToiOSApp
}
}
func sendFileToiOSApp () {guard isSessionActive() else {
		print("\(#function): Session not activated")
		return
}
if (session.isReachable) {
/* Sending log message along with activate message*/
let message = getActivateMessage()
self.session.sendMessage(message, replyHandler: { replyMessage in
let metaData = [WCKEY.FILENAME: self.fileSentToServer[0].lastPathComponent]
self.fileTransferSession = self.session.transferFile(self.fileSentToServer[0], metadata: metaData)
print ("\(#function): iphone activated,transferring file")
UserDefaults.standard.set(true, forKey: UDKEY.WATCHAWAITINGRESP)
}, errorHandler: { error in
print ("Error reaching iOS, Retrying..")
let err = error as! WCError
if (err.code != WCError.Code.notReachable) { /* wait till reachability status change*/
DispatchQueue.main.async {
self.sendFileToApp()
}
}
})
}
}
Code on iOS side
func session( session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
let msgKey = message[WCKEY.MESSAGEKEY] as! String
print ("\(#function): for \(msgKey)")
if (msgKey == WCKEY.ACTIVATE) {
let replyMessage: [String: Any] = [WCKEY.STATUS: WCKEY.ACTIVATED]
replyHandler (replyMessage)
}
}
func session( session: WCSession, didReceive file: WCSessionFile) {
print ("\(#function): \(file.fileURL.lastPathComponent)")
let destFile = FileUtility.getUrl(file.fileURL)
if (FileUtility.moveFile(from: file.fileURL, to: destFile)) {
print ("\(#function): Move to \(destFile.absoluteString)")
self.accessQueue.async {
//Processing the file
}
}
}
accessQueue is the serial queue created as let accessQueue = DispatchQueue (label: "xxxxxAccessQueue", qos: .default)
I have tried with dispatch queue main too.
How to send file when watch also in background?