Apnea Board Forum - CPAP | Sleep Apnea
O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - Printable Version

+- Apnea Board Forum - CPAP | Sleep Apnea (https://www.apneaboard.com/forums)
+-- Forum: Public Area (https://www.apneaboard.com/forums/Forum-Public-Area)
+--- Forum: Software Support Forum (https://www.apneaboard.com/forums/Forum-Software-Support-Forum)
+--- Thread: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? (/Thread-O2-Insight-Pro-Where-How-are-Sleep-Reports-Data-Stored)



O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - DavidEsp - 04-04-2023

Where are the Sleep Reports (or the data they are based on) stored in O2 Insight Pro for macOS, and how could I correct their datetimes?

The reason I ask is that sometimes the O2Ring gets the start date/time wrong (for unknown reason).
For example the other night my sleep start was 22:28 but the ring recorded the start as being 14:28.

As posted earlier, the fix regarding getting the correct datetime in OSCAR is staggeringly simple - just edit the (binary) file name.

However, I'd still like to fix what O2 Insight Pro has already read-in (directly, e.g. via BlueTooth) from the O2Ring.

I tried altering the file name and also the datetimes in the (SQLite) database used by O2 Insight. This fix part-worked, making the correct date/time appear in the left-hand panel of O2 Insight. However the "Sleep Report" it displayed (when I clicked on that date/time) still showed the original (wrong) date/time.

So I wonder, where are these Sleep Reports (or the data they are based on) stored? I am not talking about exporting PDF/CSV, just the "under the hood" stuff upon which the "Sleep Report" displayed on-screen by O2 Insight is based. For example so that I can try editing or even deleting the "offending" one to see if it gets regenerated with the correct datetime (i.e. matching the one in the filename and database).

Anyone know? Or any relevant tips?


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - DavidEsp - 04-04-2023

BTW: These are the steps I followed to "part-fix" the Sleep report datetimes:
* I closed O2 Insight Pro
* I corrected this file to instead be named: "20230331222850", reflecting 22:28
* I then edited O2 Insight's database (in SQLite): "db_o2.db", as follows...
* In Table "tb_check", for the relevant entry/row I changed the values in columns "flowid", "checktime" and "startDateTime" to include the correct datetime (as per the renamed file)
* I wrote (saved) these changes to the database

Following that, I opened O2 Insight Pro
In its left-hand panel, the list of sessions now showed the edited entry with its correct time: 22:28
When I clicked on that entry, the main window area showed the corresponding "Sleep report"
However, the times displayed in it were still wrong - showing a start-time of 14:18

I guess that the Sleep Report originally generated for the session/file/database-entry must be getting re-used here?


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - Crimson Nape - 04-04-2023

I'm Mac challenged, so go with me on this.  The Windows version of O2 Insight Pro has a "Configure" button where you can set the device's time and date.  Another option is to get the mobile app, ViHealth.  This will allow you to connect via Bluetooth to the device.  When ViHealth connects to the device, its time/date is automatically updated.

- Red


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - DavidEsp - 04-04-2023

Thank you for trying to help, though I'm familiar with all that.

My question is more "under the hood" of O2 Insight.

I know about the Sync Clock option - but that would only affect future recordings.
Also I know how to fix timestamps onbinary data files and their corresponding entries in O2 Insight's database.

I am seeking a way to fix incorrect timestamps on existing Sleep Reports, that were produced when I first downloaded their corresponding data (binary files) into O2 Insight.
I expect that can only be achieved by a "hack" type of method.

Thank you anyhow.


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - Crimson Nape - 04-04-2023

Since your thread deals with a software issue, I am moving it to the Software Support Forum.

- Red


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - DavidEsp - 04-04-2023

Oops, sorry, yes, that's where it belongs.


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - SleepyMac - 04-05-2023

Here’s the path on my Mac (Old MacBook running Monterey)

/Users/me/Library/Containers/com.viatom.O2PCViewer-BLE/Data/Library/Application Support/O2_Insight_Pro/DATA/Serial_Number/

“Serial Number” corresponds to my O2 ring.

Hope that’s useful


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - DavidEsp - 04-05-2023

Thanks, though I already knew about that - the path to O2Insight's imported binary files.
Indeed, these are the very files I referred to in my original post:
"I tried altering the file name and also the datetimes in the (SQLite) database used by O2 Insight."

As I explained, these alterations succeeded in getting the correct date and time to appear in the left-hand panel of O2Insight, but when I clicked on these the "Sleep Report" in the main part of the Window still had the old (incorrect) datetimes.

So my question is: what else needs changing, in order to either correct those sleep reports or delete them so that they (maybe?) get regenerated. Any advice appreciatd.


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - Crimson Nape - 04-05-2023

The binary file has the date and start time embedded in its header data.  You would have to edit each file with a hex editor to change these.  

Here are the byte offsets and their meaning: (I've listed the data in ASCII for easier reading)
------ Year:  bytes 2 & 3(*256)  Example: (b2)231+(b3)7 = 231+1792 (7*256) = 2023
------ Month: byte 4
------ Day: byte 5
------ Hour: byte 6
------ Minute: byte 7
------ Seconds: byte 8

I hope this may help.
- Red


RE: O2 Insight Pro - Where/How are Sleep Reports/Data Stored? - DavidEsp - 04-05-2023

Yessss! SSSSiirrrrr!! You did it again!!!

That did the job fine.
Counting the byte numbers from 0 (zero) and with hex convertor (website) in hand.

So for O2 Insight (app):
* Left-hand panel displays date-time based purely on file name (text)
* Content panel displays date-time based purely on file header (binary)

I have now copied the file with modified-header over to OSCAR's data folder (which I keep separate) and that still works too (bonus!).

I had spent so many hours (over days) trying to find some kind of "other file", which clearly didn't exist...

Thanks Red,
David