Repository navigation
Storing and uploading application data #2960
|
I've a question, I have an application that downloads information from a heart rate monitor and foot pod while I run. Generally, I don't have my phone with me so need to store the information on the watch until I next get back to my phone. I would then like to send the data to a server through an HTTPS request. I currently am able to store this with data logging, but when the phone reads it, it immediately discards the data because I don't have an iPhone App for the phone to send it to. So I have to instead disable data logging sends while I'm running and not enable them again until after the phone is reconnected and the data can be handled. But even then I believe it is not possible for the Watch app to retrieve the data logging contents to then send it to the server. The only other way to store the data is in memory (which will be lost if the app is accidentally exited) or in persistent storage which is limited to 4kB Is there something I'm missing here? Is it possible to have it set up so that third party data logging can be sent to an external server from the Pebble iphone App? |
Replies: 2 comments 3 replies
|
The watch itself doesn't have an IP stack or direct internet access, and persistent storage on-device is indeed capped at 4 kB ( The canonical architecture in PebbleOS for logging data on the watch and offloading it to a remote server is the DataLogging API paired with PebbleKit JS (PKJS) running on the companion phone app: 1. On the watch (C code): // Setup a datalogging session
DataLoggingSessionRef session = data_logging_create(
LOG_TAG_SENSORS,
DATA_LOGGING_BYTE_ARRAY,
sizeof(MySensorRecord),
true // resume existing session if available
);
// Log a data sample
MySensorRecord record = { .timestamp = time(NULL), .val = sensor_val };
data_logging_log(session, &record, 1);
// When finished:
data_logging_finish(session);2. On the companion phone (PebbleKit JS / For continuous streams or when PKJS datalogging isn't available, the standard fallback is AppMessage:
|
|
In https://developer.rebble.io/guides/communication/datalogging/ it says: Note: Datalogging data cannot be received via PebbleKit JS. I believe the AppMessage solution will be limited to the 4kb RAM available. For something like these sensors even compressed this will capture significantly more information over an hour of running. Would it be feasible to support a data logging capability that can be retained and read back by the watch app when the phone is back? Or some way of storing the third party data in the phone app for later transmission? |
You're right about PKJS—the JavaScript runtime in the mobile app never exposed the data logging callbacks; that was strictly implemented in native PebbleKit on Android (
PebbleKit.registerDataLogReceiver) and iOS (PBDataLoggingService).Regarding retaining data and phone-side sync:
1. Watch flash vs the 4 kB limit
The 4 kB cap on
persist_write_*is purely a software quota enforced by PFS (Pebble File System) to keep individual app KV stores from monopolizing flash sectors. The DataLogging subsystem itself actually spools directly into dedicated circular buffer sectors on the SPI NOR flash (often 64–128 kB depending on firmware platform partitions). From an OS design perspective, exposing a…