OMAPI  1.8
Open Movement Public API
omapi.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2012, Newcastle University, UK.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23  * POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 
27 
119 /*
120  @section example_code Example code
121  Code examples are included that cover a range of uses of the API.
122  See the following files in the "Examples" section:
123  -# test - A command-line tool to self-test all connected devices, and controls the LED to indicate any failures.
124  -# deploy - A command-line tool to batch setup of all fully-charged and cleared devices, includes delayed activation and time synchronization.
125  -# download - A command-line tool to download from all devices that containing data.
126  -# clear - A command-line tool to clear all attached devices.
127  -# convert - A command-line tool to convert a specified binary data file to a CSV text file.
128 
129 <!--
130  A brief overview of each is included below.
131  @see \ref introduction
132  @see The API header file: omapi.h
133 
134  \section s_api_init API initialization and device discovery
135  \em <b>See main article:</b> \ref api_init
136  \copydoc api_init
137 
138  \section s_device_status Device status
139  \em <b>See main article:</b> \ref device_status
140  \copydoc device_status
141 
142  \section s_settings Device settings and metadata
143  \em <b>See main article:</b> \ref settings
144  \copydoc settings
145 
146  \section s_download Data download
147  \em <b>See main article:</b> \ref data_download
148  \copydoc data_download
149 
150  \section s_return_codes Return codes
151  \em <b>See main article:</b> \ref return_codes
152  \copydoc return_codes
153 
154  \section s_datetime Date/time type
155  \em <b>See main article:</b> \ref datetime
156  \copydoc datetime
157 
158  \section s_reader Binary data file reader
159  \em <b>See main article:</b> \ref reader
160  \copydoc reader
161 -->
162 
163 */
164 
181  /* Include guard */
182  #ifndef OM_H
183  #define OM_H
184 
185 
186 /* Plain C for undecorated function names in DLL */
187 #ifdef __cplusplus
188 extern "C" {
189 #endif
190 
191 
196 #if defined(_WIN32) && defined(_WINDLL)
197  #define OM_EXPORT __declspec(dllexport)
198 #elif defined(_WIN32) && defined(OMAPI_DYNLIB_IMPORT)
199  #define OM_EXPORT __declspec(dllimport)
200 #else
201  #define OM_EXPORT
202 #endif
203 
225 #define OM_VERSION 108
226 
227 
239 OM_EXPORT int OmStartup(int version);
240 
241 
250 OM_EXPORT int OmShutdown(void);
251 
252 
260 OM_EXPORT int OmSetLogStream(int fd);
261 
262 
270 typedef void(*OmLogCallback)(void *, const char *);
271 
272 
280 OM_EXPORT int OmSetLogCallback(OmLogCallback logCallback, void *reference);
281 
282 
287 typedef enum
288 {
292 
293 
300 typedef void(*OmDeviceCallback)(void *, int, OM_DEVICE_STATUS);
301 
302 
310 OM_EXPORT int OmSetDeviceCallback(OmDeviceCallback deviceCallback, void *reference);
311 
312 
322 OM_EXPORT int OmGetDeviceIds(int *deviceIds, int maxDevices);
323 
324 
329 /* A single integer value is used to pack the date/time for a simpler, cross-language, API.
330  * (Defined here before its documentation, grouped with the other time functions below)
331  */
332 typedef unsigned long OM_DATETIME;
333 
334 
335 
367 OM_EXPORT int OmGetVersion(int deviceId, int *firmwareVersion, int *hardwareVersion);
368 
369 
376 OM_EXPORT int OmGetDeviceSerial(int deviceId, char *serialBuffer);
377 
378 
386 OM_EXPORT int OmGetDevicePort(int deviceId, char *portBuffer);
387 
388 
396 OM_EXPORT int OmGetDevicePath(int deviceId, char *pathBuffer);
397 
398 
405 OM_EXPORT int OmGetBatteryLevel(int deviceId);
406 
407 
416 OM_EXPORT int OmSelfTest(int deviceId);
417 
418 
429 OM_EXPORT int OmGetMemoryHealth(int deviceId);
430 
431 #define OM_MEMORY_HEALTH_ERROR 1
432 #define OM_MEMORY_HEALTH_WARNING 8
443 OM_EXPORT int OmGetBatteryHealth(int deviceId);
444 
445 
455 OM_EXPORT int OmGetAccelerometer(int deviceId, int *x, int *y, int *z);
456 
457 
464 OM_EXPORT int OmGetTime(int deviceId, OM_DATETIME *time);
465 
466 
473 OM_EXPORT int OmSetTime(int deviceId, OM_DATETIME time);
474 
475 
484 typedef enum
485 {
486  OM_LED_AUTO = -1,
495 } OM_LED_STATE;
496 
497 
505 OM_EXPORT int OmSetLed(int deviceId, OM_LED_STATE ledState);
506 
507 
515 OM_EXPORT int OmIsLocked(int deviceId, int *hasLockCode);
516 
517 
526 OM_EXPORT int OmSetLock(int deviceId, unsigned short code);
527 
528 
537 OM_EXPORT int OmUnlock(int deviceId, unsigned short code);
538 
539 
547 OM_EXPORT int OmSetEcc(int deviceId, int state);
548 
549 
556 OM_EXPORT int OmGetEcc(int deviceId);
557 
558 
575 OM_EXPORT int OmCommand(int deviceId, const char *command, char *buffer, size_t bufferSize, const char *expected, unsigned int timeoutMs, char **parseParts, int parseMax);
576 
577 
608 OM_EXPORT int OmGetDelays(int deviceId, OM_DATETIME *startTime, OM_DATETIME *stopTime);
609 
610 
626 OM_EXPORT int OmSetDelays(int deviceId, OM_DATETIME startTime, OM_DATETIME stopTime);
627 
628 
635 OM_EXPORT int OmGetSessionId(int deviceId, unsigned int *sessionId);
636 
637 
646 OM_EXPORT int OmSetSessionId(int deviceId, unsigned int sessionId);
647 
648 
653 #define OM_METADATA_SIZE 448
654 
655 
663 OM_EXPORT int OmGetMetadata(int deviceId, char *metadata);
664 
665 
676 OM_EXPORT int OmSetMetadata(int deviceId, const char *metadata, int size);
677 
678 
685 OM_EXPORT int OmGetLastConfigTime(int deviceId, OM_DATETIME *time);
686 
687 
693 typedef enum
694 {
700 
701 
720 OM_EXPORT int OmEraseDataAndCommit(int deviceId, OM_ERASE_LEVEL eraseLevel);
721 
722 
732 #define OmClearDataAndCommit(_deviceId) OmEraseDataAndCommit((_deviceId), OM_ERASE_QUICKFORMAT)
733 
734 
745 #define OmCommit(_deviceId) OmEraseDataAndCommit((_deviceId), OM_ERASE_NONE)
746 
747 
753 #define OM_ACCEL_DEFAULT_RATE 100
754 
755 
761 #define OM_ACCEL_DEFAULT_RANGE 8
762 
763 
773 OM_EXPORT int OmGetAccelConfig(int deviceId, int *rate, int *range);
774 
775 
786 OM_EXPORT int OmSetAccelConfig(int deviceId, int rate, int range);
787 
788 
797 OM_EXPORT int OmGetMaxSamples(int deviceId, int *value);
798 
799 
809 OM_EXPORT int OmSetMaxSamples(int deviceId, int value);
810 
811 
812 
840 #define OM_MAX_PATH (256)
841 
842 
847 typedef enum
848 {
855 
856 
863 typedef void(*OmDownloadCallback)(void *, int, OM_DOWNLOAD_STATUS, int);
864 
865 
873 typedef void(*OmDownloadChunkCallback)(void *, int, void *, int, int);
874 
875 
882 OM_EXPORT int OmSetDownloadCallback(OmDownloadCallback downloadCallback, void *reference);
883 
884 
892 OM_EXPORT int OmSetDownloadChunkCallback(OmDownloadChunkCallback downloadChunkCallback, void *reference);
893 
894 
901 OM_EXPORT int OmGetDataFileSize(int deviceId);
902 
903 
911 OM_EXPORT int OmGetDataFilename(int deviceId, char *filenameBuffer);
912 
913 
924 OM_EXPORT int OmGetDataRange(int deviceId, int *dataBlockSize, int *dataOffsetBlocks, int *dataNumBlocks, OM_DATETIME *startTime, OM_DATETIME *endTime);
925 
926 
940 OM_EXPORT int OmBeginDownloading(int deviceId, int dataOffsetBlocks, int dataLengthBlocks, const char *destinationFile);
941 
942 
958 OM_EXPORT int OmBeginDownloadingReference(int deviceId, int dataOffsetBlocks, int dataLengthBlocks, const char *destinationFile, void *reference);
959 
960 
973 OM_EXPORT int OmQueryDownload(int deviceId, OM_DOWNLOAD_STATUS *downloadStatus, int *downloadValue);
974 
975 
988 OM_EXPORT int OmWaitForDownload(int deviceId, OM_DOWNLOAD_STATUS *downloadStatus, int *downloadValue);
989 
990 
998 OM_EXPORT int OmCancelDownload(int deviceId);
999 
1017 #define OM_TRUE 1
1018 #define OM_FALSE 0
1019 #define OM_OK 0
1020 #define OM_E_FAIL -1
1021 #define OM_E_UNEXPECTED -2
1022 #define OM_E_NOT_VALID_STATE -3
1023 #define OM_E_OUT_OF_MEMORY -4
1024 #define OM_E_INVALID_ARG -5
1025 #define OM_E_POINTER -6
1026 #define OM_E_NOT_IMPLEMENTED -7
1027 #define OM_E_ABORT -8
1028 #define OM_E_ACCESS_DENIED -9
1029 #define OM_E_INVALID_DEVICE -10
1030 #define OM_E_UNEXPECTED_RESPONSE -11
1031 #define OM_E_LOCKED -12
1032 #define OM_SUCCEEDED(value) ((value) >= 0)
1033 #define OM_FAILED(value) ((value) < 0)
1041 OM_EXPORT const char *OmErrorString(int status);
1042 
1067 /*typedef unsigned long OM_DATETIME;*/ /* (defined earlier in the file) */
1068 
1073 #define OM_DATETIME_FROM_YMDHMS(year, month, day, hours, minutes, seconds) \
1074  ( (((OM_DATETIME)((year) % 100) & 0x3f) << 26) \
1075  | (((OM_DATETIME)(month) & 0x0f) << 22) \
1076  | (((OM_DATETIME)(day) & 0x1f) << 17) \
1077  | (((OM_DATETIME)(hours) & 0x1f) << 12) \
1078  | (((OM_DATETIME)(minutes) & 0x3f) << 6) \
1079  | (((OM_DATETIME)(seconds) & 0x3f) ) \
1080  )
1081 #define OM_DATETIME_YEAR(dateTime) ((unsigned int)((unsigned char)(((dateTime) >> 26) & 0x3f)) + 2000)
1082 #define OM_DATETIME_MONTH(dateTime) ((unsigned char)(((dateTime) >> 22) & 0x0f))
1083 #define OM_DATETIME_DAY(dateTime) ((unsigned char)(((dateTime) >> 17) & 0x1f))
1084 #define OM_DATETIME_HOURS(dateTime) ((unsigned char)(((dateTime) >> 12) & 0x1f))
1085 #define OM_DATETIME_MINUTES(dateTime) ((unsigned char)(((dateTime) >> 6) & 0x3f))
1086 #define OM_DATETIME_SECONDS(dateTime) ((unsigned char)(((dateTime) ) & 0x3f))
1087 #define OM_DATETIME_MIN_VALID OM_DATETIME_FROM_YMDHMS(2000, 1, 1, 0, 0, 0)
1088 #define OM_DATETIME_MAX_VALID OM_DATETIME_FROM_YMDHMS(2063, 12, 31, 23, 59, 59)
1089 #define OM_DATETIME_ZERO (0)
1090 #define OM_DATETIME_INFINITE ((OM_DATETIME)-1)
1093 #define OM_DATETIME_BUFFER_SIZE (20)
1094 
1096 OM_EXPORT OM_DATETIME OmDateTimeFromString(const char *value);
1097 
1099 //#define OmDateTimeToString(value, buffer) (((value) < OM_DATETIME_MIN_VALID) ? "0" : (((value) > OM_DATETIME_MAX_VALID) ? "-1" : (sprintf(buffer, "%04u-%02u-%02u %02u:%02u:%02u", OM_DATETIME_YEAR(value), OM_DATETIME_MONTH(value), OM_DATETIME_DAY(value), OM_DATETIME_HOURS(value), OM_DATETIME_MINUTES(value), OM_DATETIME_SECONDS(value)), buffer)))
1100 OM_EXPORT char *OmDateTimeToString(OM_DATETIME value, char *buffer);
1101 
1102 
1127 typedef void * OmReaderHandle;
1128 
1129 
1134 #define OM_MAX_SAMPLES (120)
1135 
1136 
1141 #define OM_MAX_HEADER_SIZE (2 * 512)
1142 
1143 
1148 #define OM_MAX_DATA_SIZE (512)
1149 
1150 
1158 OM_EXPORT OmReaderHandle OmReaderOpen(const char *binaryFilename);
1159 
1160 
1171 OM_EXPORT int OmReaderDataRange(OmReaderHandle reader, int *dataBlockSize, int *dataOffsetBlocks, int *dataNumBlocks, OM_DATETIME *startTime, OM_DATETIME *endTime);
1172 
1173 
1181 OM_EXPORT const char *OmReaderMetadata(OmReaderHandle reader, int *deviceId, unsigned int *sessionId);
1182 
1183 
1189 OM_EXPORT int OmReaderDataBlockPosition(OmReaderHandle reader);
1190 
1191 
1198 OM_EXPORT int OmReaderDataBlockSeek(OmReaderHandle reader, int dataBlockNumber);
1199 
1200 
1210 OM_EXPORT int OmReaderNextBlock(OmReaderHandle reader);
1211 
1212 
1222 OM_EXPORT short *OmReaderBuffer(OmReaderHandle reader);
1223 
1224 
1237 OM_EXPORT OM_DATETIME OmReaderTimestamp(OmReaderHandle reader, int index, unsigned short *fractional);
1238 
1239 
1245 typedef enum
1246 {
1248  OM_VALUE_DEVICEID = 3,
1249  OM_VALUE_SESSIONID = 4,
1250  OM_VALUE_SEQUENCEID = 5,
1254  OM_VALUE_TEMPERATURE = 8,
1255  OM_VALUE_EVENTS = 9,
1256  OM_VALUE_BATTERY = 10,
1257  OM_VALUE_SAMPLERATE = 11,
1258  OM_VALUE_LIGHT_LOG10LUXTIMES10POWER3 = 107,
1262  OM_VALUE_BATTERY_MV = 110,
1263  OM_VALUE_BATTERY_PERCENT = 210,
1273 
1274 
1284 OM_EXPORT int OmReaderGetValue(OmReaderHandle reader, OM_READER_VALUE_TYPE valueType);
1285 
1286 
1291 #pragma pack(push, 1)
1292 typedef struct
1293 {
1294  unsigned short packetHeader;
1295  unsigned short packetLength;
1296  unsigned char reserved1;
1297  unsigned short deviceId;
1298  unsigned int sessionId;
1299  unsigned short reserved2;
1302  unsigned int loggingCapacity;
1303  unsigned char reserved3[11];
1304  unsigned char samplingRate;
1305  unsigned int lastChangeTime;
1306  unsigned char firmwareRevision;
1307  signed short timeZone;
1308  unsigned char reserved4[20];
1309  unsigned char annotation[OM_METADATA_SIZE];
1310  unsigned char reserved[512];
1312 #pragma pack(pop)
1313 
1314 
1323 
1324 
1329 #pragma pack(push, 1)
1330 typedef struct
1331 {
1332  unsigned short packetHeader;
1333  unsigned short packetLength;
1334  unsigned short deviceFractional;
1335  unsigned int sessionId;
1336  unsigned int sequenceId;
1338  unsigned short light;
1339  unsigned short temperature;
1340  unsigned char events;
1341  unsigned char battery;
1342  unsigned char sampleRate;
1343  unsigned char numAxesBPS;
1344  signed short timestampOffset;
1345  unsigned short sampleCount;
1346  unsigned char rawSampleData[480];
1347  unsigned short checksum;
1349 #pragma pack(pop)
1350 
1351 
1361 
1362 
1369 OM_EXPORT void OmReaderClose(OmReaderHandle reader);
1370 
1375 #ifdef __cplusplus
1376 }
1377 #endif
1378 
1379 
1380 #endif
OmSetSessionId
int OmSetSessionId(int deviceId, unsigned int sessionId)
Sets the specified device's session identifier to be used at the next recording session.
OM_READER_DATA_PACKET::deviceFractional
unsigned short deviceFractional
@ 4 +2 Top bit set: 15-bit fraction of a second for the time stamp, the timestampOffset was already a...
Definition: omapi.h:1334
OM_ERASE_LEVEL
OM_ERASE_LEVEL
Erase levels for OmEraseDataAndCommit() function.
Definition: omapi.h:693
OM_DEVICE_REMOVED
Device is being removed, or is already removed.
Definition: omapi.h:289
OmCancelDownload
int OmCancelDownload(int deviceId)
Cancel the current download of the data on the specified device.
OM_DEVICE_CONNECTED
Device has been connected.
Definition: omapi.h:290
OM_READER_DATA_PACKET::sampleCount
unsigned short sampleCount
@28 +2 Number of accelerometer samples (80 or 120)
Definition: omapi.h:1345
OmSetDeviceCallback
int OmSetDeviceCallback(OmDeviceCallback deviceCallback, void *reference)
Sets the callback function that is called whenever a device is added or removed.
OM_READER_DATA_PACKET::checksum
unsigned short checksum
@510 +2 Checksum of packet (16-bit word-wise sum of the whole packet should be zero)
Definition: omapi.h:1347
OM_READER_HEADER_PACKET::packetLength
unsigned short packetLength
@ 2 +2 Packet length (1020 bytes, with header (4) = 1024 bytes total)
Definition: omapi.h:1295
OmGetMemoryHealth
int OmGetMemoryHealth(int deviceId)
Determine the health of the NAND flash memory on the specified device.
OM_DATETIME
unsigned long OM_DATETIME
Definition: omapi.h:332
OmReaderDataRange
int OmReaderDataRange(OmReaderHandle reader, int *dataBlockSize, int *dataOffsetBlocks, int *dataNumBlocks, OM_DATETIME *startTime, OM_DATETIME *endTime)
Read the size, time-range, and internal chunking of the binary file.
OM_LED_RED
rgb(1,0,0) Red
Definition: omapi.h:491
OmIsLocked
int OmIsLocked(int deviceId, int *hasLockCode)
Checks whether the device is currently locked.
OM_READER_HEADER_PACKET::loggingStartTime
OM_DATETIME loggingStartTime
@13 +4 Start time for delayed logging
Definition: omapi.h:1300
OM_VALUE_SCALE_GYRO
Scaling: number of degrees per second that (2^15=)32768 represents: AX6= 2000, 1000,...
Definition: omapi.h:1267
OmDeviceCallback
void(* OmDeviceCallback)(void *, int, OM_DEVICE_STATUS)
Device change callback function type.
Definition: omapi.h:300
OM_DOWNLOAD_COMPLETE
Data download completed successfully.
Definition: omapi.h:852
OmSetMaxSamples
int OmSetMaxSamples(int deviceId, int value)
Sets the specified device's 'maximum sample' value.
OM_VALUE_SCALE_ACCEL
Scaling: number of units for 1g: CWA=256, AX6=2048 (+/-16g), 4096 (+/-8g), 8192 (+/-4g),...
Definition: omapi.h:1266
OmCommand
int OmCommand(int deviceId, const char *command, char *buffer, size_t bufferSize, const char *expected, unsigned int timeoutMs, char **parseParts, int parseMax)
Issues a direct command over the CDC port for a particular device.
OM_READER_HEADER_PACKET
Internal structure of a binary file header block.
Definition: omapi.h:1292
OM_READER_DATA_PACKET
Internal structure of a binary file data block.
Definition: omapi.h:1330
OM_LED_YELLOW
rgb(1,1,0) Yellow
Definition: omapi.h:493
OM_ERASE_QUICKFORMAT
Device file-system is re-created and a new data file is created with the current metadata.
Definition: omapi.h:697
OM_ERASE_NONE
Data file not erased but metadata just updated (this is not recommended as it could lead to a data/me...
Definition: omapi.h:695
OM_READER_HEADER_PACKET::loggingEndTime
OM_DATETIME loggingEndTime
@17 +4 Stop time for delayed logging
Definition: omapi.h:1301
OM_DOWNLOAD_NONE
No download information.
Definition: omapi.h:849
OM_READER_DATA_PACKET::events
unsigned char events
@22 +1 Event flags since last packet, b0 = resume logging, b1 = single-tap event, b2 = double-tap eve...
Definition: omapi.h:1340
OM_READER_DATA_PACKET::battery
unsigned char battery
@23 +1 Last recorded battery level in raw units, 0 = unknown
Definition: omapi.h:1341
OmReaderMetadata
const char * OmReaderMetadata(OmReaderHandle reader, int *deviceId, unsigned int *sessionId)
Read the device id, session id and metadata of the binary file.
OM_VALUE_TEMPERATURE_MC
Temperature sensor reading in milli-centigrade.
Definition: omapi.h:1260
OmReaderNextBlock
int OmReaderNextBlock(OmReaderHandle reader)
Reads the next block of data from the binary file.
OmGetAccelerometer
int OmGetAccelerometer(int deviceId, int *x, int *y, int *z)
Gets the specified device's current accelerometer values.
OmReaderClose
void OmReaderClose(OmReaderHandle reader)
Closes the specified reader handle.
OmReaderGetValue
int OmReaderGetValue(OmReaderHandle reader, OM_READER_VALUE_TYPE valueType)
Returns a specific value type from the buffer read by OmReaderNextBlock().
OmSetLed
int OmSetLed(int deviceId, OM_LED_STATE ledState)
Sets the specified device's LED colour.
OM_LED_CYAN
rgb(0,1,1) Cyan
Definition: omapi.h:490
OmReaderDataBlockSeek
int OmReaderDataBlockSeek(OmReaderHandle reader, int dataBlockNumber)
Seeks the file reader to the specified data block.
OM_READER_HEADER_PACKET::samplingRate
unsigned char samplingRate
@36 +1 Sampling rate
Definition: omapi.h:1304
OM_READER_HEADER_PACKET::loggingCapacity
unsigned int loggingCapacity
@21 +4 Preset maximum number of samples to collect, 0 = unlimited
Definition: omapi.h:1302
OmGetDevicePort
int OmGetDevicePort(int deviceId, char *portBuffer)
Return the path to specified device's communication port.
OM_VALUE_MAG_AXIS
Axis index for Mag-X (-Y and -Z follow), AX6(GAM)=6, not-present=-1.
Definition: omapi.h:1271
OmGetEcc
int OmGetEcc(int deviceId)
Gets the error-correcting code flag for the specified device.
OmWaitForDownload
int OmWaitForDownload(int deviceId, OM_DOWNLOAD_STATUS *downloadStatus, int *downloadValue)
This function waits for the specified device's asynchronous download to finish.
OmBeginDownloading
int OmBeginDownloading(int deviceId, int dataOffsetBlocks, int dataLengthBlocks, const char *destinationFile)
Begin downloading the data from the current device.
OmQueryDownload
int OmQueryDownload(int deviceId, OM_DOWNLOAD_STATUS *downloadStatus, int *downloadValue)
This function queries the status of the specified device's asynchronous download.
OmBeginDownloadingReference
int OmBeginDownloadingReference(int deviceId, int dataOffsetBlocks, int dataLengthBlocks, const char *destinationFile, void *reference)
Begin downloading the data from the current device, passing an additional reference.
OmSetAccelConfig
int OmSetAccelConfig(int deviceId, int rate, int range)
Sets the specified device's accelerometer configuration to be used at the next recording session.
OM_READER_HEADER_PACKET::lastChangeTime
unsigned int lastChangeTime
@37 +4 Last change metadata time
Definition: omapi.h:1305
OmGetVersion
int OmGetVersion(int deviceId, int *firmwareVersion, int *hardwareVersion)
Returns the firmware and hardware versions of the specified device.
OmGetBatteryLevel
int OmGetBatteryLevel(int deviceId)
Queries the specified device for the current battery charging level.
OM_VALUE_ACCEL_AXIS
Axis index for Accel-X (-Y and -Z follow), AX3=0, AX6(A)=0, AX6(GA/GAM)=3, not-present=-1.
Definition: omapi.h:1269
OM_DOWNLOAD_ERROR
Data download failed with an error (the value parameter to OmDownloadCallback indicates a diagnostic ...
Definition: omapi.h:850
OM_VALUE_GYRO_AXIS
Axis index for Gyro-X (-Y and -Z follow), AX6(GA/GAM)=0, not-present=-1.
Definition: omapi.h:1270
OmGetMaxSamples
int OmGetMaxSamples(int deviceId, int *value)
Queries the specified device's 'maximum sample' value.
OmGetSessionId
int OmGetSessionId(int deviceId, unsigned int *sessionId)
Queries the specified device's session identifier.
OmGetAccelConfig
int OmGetAccelConfig(int deviceId, int *rate, int *range)
Queries the specified device's accelerometer configuration.
OM_READER_DATA_PACKET::sampleRate
unsigned char sampleRate
@24 +1 Sample rate code, (3200/(1<<(15-(rate & 0x0f)))) Hz
Definition: omapi.h:1342
OmSetDownloadChunkCallback
int OmSetDownloadChunkCallback(OmDownloadChunkCallback downloadChunkCallback, void *reference)
Sets the chunk callback function that is called when a new download chunk is received.
OmLogCallback
void(* OmLogCallback)(void *, const char *)
Log callback function type.
Definition: omapi.h:270
OmReaderRawHeaderPacket
OM_READER_HEADER_PACKET * OmReaderRawHeaderPacket(OmReaderHandle reader)
Accesses the contents of a raw header packet.
OmSetTime
int OmSetTime(int deviceId, OM_DATETIME time)
Sets the specified device's internal real time clock.
logCallback
void logCallback(void *reference, const char *message)
Definition: download.c:65
OM_READER_DATA_PACKET::timestamp
OM_DATETIME timestamp
@14 +4 Last reported RTC value, 0 = unknown
Definition: omapi.h:1337
OM_LED_OFF
rgb(0,0,0) Off
Definition: omapi.h:487
OmGetDataRange
int OmGetDataRange(int deviceId, int *dataBlockSize, int *dataOffsetBlocks, int *dataNumBlocks, OM_DATETIME *startTime, OM_DATETIME *endTime)
Read the size, time-range, and internal chunking of the data buffer.
OM_READER_HEADER_PACKET::sessionId
unsigned int sessionId
@ 7 +4 Unique session identifier
Definition: omapi.h:1298
OM_VALUE_SCALE_MAG
Scaling: number of units for 1uT: AX6=16.
Definition: omapi.h:1268
OM_READER_HEADER_PACKET::packetHeader
unsigned short packetHeader
@ 0 +2 ASCII "MD", little-endian (0x444D)
Definition: omapi.h:1294
OM_LED_MAGENTA
rgb(1,0,1) Magenta
Definition: omapi.h:492
OmSetLock
int OmSetLock(int deviceId, unsigned short code)
Sets the lock code for the device when it is connected.
OmReaderTimestamp
OM_DATETIME OmReaderTimestamp(OmReaderHandle reader, int index, unsigned short *fractional)
Determines the timestamp of the specified sample in the buffer read by OmReaderNextBlock().
OmGetLastConfigTime
int OmGetLastConfigTime(int deviceId, OM_DATETIME *time)
Returns the date and time that the specified device was last configured.
OM_DOWNLOAD_PROGRESS
Data download progress (the value parameter to OmDownloadCallback indicates progress percentage)
Definition: omapi.h:851
OmGetDataFilename
int OmGetDataFilename(int deviceId, char *filenameBuffer)
Return the path to the data file for the specified device.
OmShutdown
int OmShutdown(void)
Shuts down the Open Movement API.
OmSetDelays
int OmSetDelays(int deviceId, OM_DATETIME startTime, OM_DATETIME stopTime)
Sets the specified device's delayed activation start and stop times to use for a new recording sessio...
OM_READER_HEADER_PACKET::reserved2
unsigned short reserved2
@11 +2 (2 bytes reserved)
Definition: omapi.h:1299
OmReaderDataBlockPosition
int OmReaderDataBlockPosition(OmReaderHandle reader)
Return the current block index of the reader.
OM_ERASE_WIPE
All blocks on the NAND flash memory are cleared, the file-system is cleanly re-created,...
Definition: omapi.h:698
OmGetDeviceSerial
int OmGetDeviceSerial(int deviceId, char *serialBuffer)
Return the full USB serial string identity for the specified device.
OM_LED_GREEN
rgb(0,1,0) Green
Definition: omapi.h:489
OmReaderOpen
OmReaderHandle OmReaderOpen(const char *binaryFilename)
Opens a binary data file for reading.
OmGetTime
int OmGetTime(int deviceId, OM_DATETIME *time)
Queries the specified device's internal real time clock.
OM_READER_HEADER_PACKET::timeZone
signed short timeZone
@42 +2 Time Zone offset from UTC (in minutes), 0xffff = -1 = unknown
Definition: omapi.h:1307
OmGetDelays
int OmGetDelays(int deviceId, OM_DATETIME *startTime, OM_DATETIME *stopTime)
Gets the specified device's delayed activation start and stop times.
OM_LED_AUTO
Automatic device-controlled LED to indicate state (default).
Definition: omapi.h:486
OmSetLogCallback
int OmSetLogCallback(OmLogCallback logCallback, void *reference)
Sets the callback function that is called whenever an API log message is written.
OM_LED_STATE
OM_LED_STATE
Enumeration of LED colours.
Definition: omapi.h:484
OM_LED_WHITE
rgb(1,1,1) White
Definition: omapi.h:494
OmSelfTest
int OmSelfTest(int deviceId)
Performs a firmware-specific self-test on the specified device (e.g.
OmGetDevicePath
int OmGetDevicePath(int deviceId, char *pathBuffer)
Return the path to specified device's filesystem.
OmGetMetadata
int OmGetMetadata(int deviceId, char *metadata)
Gets the contents of the specified device's metadata scratch buffer.
OmSetLogStream
int OmSetLogStream(int fd)
Sets the stream to use for log messages.
OM_READER_DATA_PACKET::sequenceId
unsigned int sequenceId
@10 +4 Sequence counter, each packet has a new number (reset if restarted)
Definition: omapi.h:1336
OmUnlock
int OmUnlock(int deviceId, unsigned short code)
Sets the lock code for the device when it is connected.
OM_READER_DATA_PACKET::temperature
unsigned short temperature
@20 +2 Last recorded temperature sensor value in raw units, 0 = none
Definition: omapi.h:1339
OM_READER_DATA_PACKET::timestampOffset
signed short timestampOffset
@26 +2 Relative sample index from the start of the buffer where the whole-second timestamp is valid
Definition: omapi.h:1344
OmGetDeviceIds
int OmGetDeviceIds(int *deviceIds, int maxDevices)
Obtains the device IDs of all connected devices.
OmReaderHandle
void * OmReaderHandle
Handle to a reader object.
Definition: omapi.h:1127
OM_READER_HEADER_PACKET::reserved1
unsigned char reserved1
@ 4 +1 (1 byte reserved)
Definition: omapi.h:1296
OM_METADATA_SIZE
#define OM_METADATA_SIZE
The number of bytes of metadata scratch area on the device.
Definition: omapi.h:653
OM_READER_DATA_PACKET::numAxesBPS
unsigned char numAxesBPS
@25 +1 0x32 (top nibble: number of axes = 3; bottom nibble: packing format - 2 = 3x 16-bit signed,...
Definition: omapi.h:1343
OM_READER_VALUE_TYPE
OM_READER_VALUE_TYPE
Reader value indexes for OmReaderGetValue() function.
Definition: omapi.h:1245
OM_LED_BLUE
rgb(0,0,1) Blue
Definition: omapi.h:488
OmGetDataFileSize
int OmGetDataFileSize(int deviceId)
Return the data file size of the specified device.
OM_READER_DATA_PACKET::sessionId
unsigned int sessionId
@ 6 +4 Unique session identifier, 0 = unknown
Definition: omapi.h:1335
OM_DOWNLOAD_CANCELLED
Data download was cancelled cleanly.
Definition: omapi.h:853
OmSetDownloadCallback
int OmSetDownloadCallback(OmDownloadCallback downloadCallback, void *reference)
Sets the callback function that is called for download progress, completion, cancellation,...
OM_DOWNLOAD_STATUS
OM_DOWNLOAD_STATUS
Download states used in the OmDownloadCallback handler.
Definition: omapi.h:847
OmSetMetadata
int OmSetMetadata(int deviceId, const char *metadata, int size)
Sets the specified device's metadata scratch buffer to be used for the next recording session.
OM_VALUE_AXES
Number of axes per sample.
Definition: omapi.h:1265
OmStartup
int OmStartup(int version)
Initializes the Open Movement API.
OmReaderBuffer
short * OmReaderBuffer(OmReaderHandle reader)
Obtains a pointer to the buffer of samples read, and unpacked, by OmReaderNextBlock().
OM_READER_DATA_PACKET::packetHeader
unsigned short packetHeader
@ 0 +2 ASCII "AX", little-endian (0x5841)
Definition: omapi.h:1332
OmSetEcc
int OmSetEcc(int deviceId, int state)
Sets the error-correcting code flag for the specified device.
OM_READER_HEADER_PACKET::firmwareRevision
unsigned char firmwareRevision
@41 +1 Firmware revision number
Definition: omapi.h:1306
OmReaderRawDataPacket
OM_READER_DATA_PACKET * OmReaderRawDataPacket(OmReaderHandle reader)
Accesses the contents of a raw data packet.
OM_ERASE_DELETE
Data file is removed and a new one created with the current metadata.
Definition: omapi.h:696
OM_READER_DATA_PACKET::packetLength
unsigned short packetLength
@ 2 +2 Packet length (508 bytes, with header (4) = 512 bytes total)
Definition: omapi.h:1333
OmEraseDataAndCommit
int OmEraseDataAndCommit(int deviceId, OM_ERASE_LEVEL eraseLevel)
Erases the specified device storage and commits the metadata and settings.
OM_VALUE_LIGHT
Raw light sensor reading.
Definition: omapi.h:1252
OM_READER_DATA_PACKET::light
unsigned short light
@18 +2 Last recorded light sensor value in raw units, 0 = none
Definition: omapi.h:1338
OmDownloadChunkCallback
void(* OmDownloadChunkCallback)(void *, int, void *, int, int)
Download chunk callback function type.
Definition: omapi.h:873
OM_DEVICE_STATUS
OM_DEVICE_STATUS
Device states used in the OmDeviceCallback handler.
Definition: omapi.h:287
OmDownloadCallback
void(* OmDownloadCallback)(void *, int, OM_DOWNLOAD_STATUS, int)
Download update callback function type.
Definition: omapi.h:863
OM_READER_HEADER_PACKET::deviceId
unsigned short deviceId
@ 5 +2 Device identifier (low 16-bits)
Definition: omapi.h:1297