Code: https://github.com/coitloz88/Garmin-Project/tree/master/BackgroundTest using vscode
Hello! I'm developing part of a project that collects Garmin's sensor data (Accel / HeartRate) in real time and sends it to user's phone.
The goals are:
1. Collect user sensor data in real time in the background of Garmin watch
2. Receive collected data from the mobile phone app connected to the Garmin watch device app
3. Provide feedback to users after performing complex calculations on the mobile phone
However, 2. & 3. were completed, but I had the following problems while doing 1.:
Each background event can occur for a maximum of 30 seconds each time, and must be at least 5 minutes apart.
→ Therefore, while collecting sensor data for 30 seconds when an event can occur in the background, it is stored in the Dictionary var, and the data is transferred to the mobile phone using the transmit() method
I tried to perform the operation by calling the callback function, registerSensorDataListener(), to perform sensor data collection every n(1~4) seconds.
In fact, if I run garmin device app in emulator app, I could see that the sensor data is collected for 30 seconds, then stops, and runs again after 5 minutes.
However, in the debugging output txt file / emulator debug console, it shows that the operation is being performed well when the app is running, but when I leave the app, the operation stops.
To summarize my questions:
1. Can't I call a callback function periodically in the background?
2. Is there any other way to iterate over the background?
3. If you have any other ideas about collecting data in real time in the background and sending it to other devices such as mobile phones, I would appreciate it. (I'm also considering browsing past records with sensor history or sending a .fit file.)
Any advice would be greatly appreciated.
I'm sorry if there were some poor expressions in English.
thank you. :D