 |
OMAPI
1.8
Open Movement Public API
|
Go to the documentation of this file.
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)
225 #define OM_VERSION 108
367 OM_EXPORT
int OmGetVersion(
int deviceId,
int *firmwareVersion,
int *hardwareVersion);
431 #define OM_MEMORY_HEALTH_ERROR 1
432 #define OM_MEMORY_HEALTH_WARNING 8
443 OM_EXPORT int OmGetBatteryHealth(int deviceId);
515 OM_EXPORT
int OmIsLocked(
int deviceId,
int *hasLockCode);
526 OM_EXPORT
int OmSetLock(
int deviceId,
unsigned short code);
537 OM_EXPORT
int OmUnlock(
int deviceId,
unsigned short code);
547 OM_EXPORT
int OmSetEcc(
int deviceId,
int state);
556 OM_EXPORT
int OmGetEcc(
int deviceId);
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);
635 OM_EXPORT
int OmGetSessionId(
int deviceId,
unsigned int *sessionId);
646 OM_EXPORT
int OmSetSessionId(
int deviceId,
unsigned int sessionId);
653 #define OM_METADATA_SIZE 448
676 OM_EXPORT
int OmSetMetadata(
int deviceId,
const char *metadata,
int size);
732 #define OmClearDataAndCommit(_deviceId) OmEraseDataAndCommit((_deviceId), OM_ERASE_QUICKFORMAT)
745 #define OmCommit(_deviceId) OmEraseDataAndCommit((_deviceId), OM_ERASE_NONE)
753 #define OM_ACCEL_DEFAULT_RATE 100
761 #define OM_ACCEL_DEFAULT_RANGE 8
840 #define OM_MAX_PATH (256)
940 OM_EXPORT
int OmBeginDownloading(
int deviceId,
int dataOffsetBlocks,
int dataLengthBlocks,
const char *destinationFile);
958 OM_EXPORT
int OmBeginDownloadingReference(
int deviceId,
int dataOffsetBlocks,
int dataLengthBlocks,
const char *destinationFile,
void *reference);
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);
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) ) \
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)
1096 OM_EXPORT
OM_DATETIME OmDateTimeFromString(
const char *value);
1100 OM_EXPORT
char *OmDateTimeToString(
OM_DATETIME value,
char *buffer);
1134 #define OM_MAX_SAMPLES (120)
1141 #define OM_MAX_HEADER_SIZE (2 * 512)
1148 #define OM_MAX_DATA_SIZE (512)
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,
1291 #pragma pack(push, 1)
1303 unsigned char reserved3[11];
1308 unsigned char reserved4[20];
1310 unsigned char reserved[512];
1329 #pragma pack(push, 1)
1346 unsigned char rawSampleData[480];
int OmSetSessionId(int deviceId, unsigned int sessionId)
Sets the specified device's session identifier to be used at the next recording session.
unsigned short deviceFractional
@ 4 +2 Top bit set: 15-bit fraction of a second for the time stamp, the timestampOffset was already a...
OM_ERASE_LEVEL
Erase levels for OmEraseDataAndCommit() function.
Device is being removed, or is already removed.
int OmCancelDownload(int deviceId)
Cancel the current download of the data on the specified device.
Device has been connected.
unsigned short sampleCount
@28 +2 Number of accelerometer samples (80 or 120)
int OmSetDeviceCallback(OmDeviceCallback deviceCallback, void *reference)
Sets the callback function that is called whenever a device is added or removed.
unsigned short checksum
@510 +2 Checksum of packet (16-bit word-wise sum of the whole packet should be zero)
unsigned short packetLength
@ 2 +2 Packet length (1020 bytes, with header (4) = 1024 bytes total)
int OmGetMemoryHealth(int deviceId)
Determine the health of the NAND flash memory on the specified device.
unsigned long OM_DATETIME
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.
int OmIsLocked(int deviceId, int *hasLockCode)
Checks whether the device is currently locked.
OM_DATETIME loggingStartTime
@13 +4 Start time for delayed logging
Scaling: number of degrees per second that (2^15=)32768 represents: AX6= 2000, 1000,...
void(* OmDeviceCallback)(void *, int, OM_DEVICE_STATUS)
Device change callback function type.
Data download completed successfully.
int OmSetMaxSamples(int deviceId, int value)
Sets the specified device's 'maximum sample' value.
Scaling: number of units for 1g: CWA=256, AX6=2048 (+/-16g), 4096 (+/-8g), 8192 (+/-4g),...
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.
Internal structure of a binary file header block.
Internal structure of a binary file data block.
Device file-system is re-created and a new data file is created with the current metadata.
Data file not erased but metadata just updated (this is not recommended as it could lead to a data/me...
OM_DATETIME loggingEndTime
@17 +4 Stop time for delayed logging
unsigned char events
@22 +1 Event flags since last packet, b0 = resume logging, b1 = single-tap event, b2 = double-tap eve...
unsigned char battery
@23 +1 Last recorded battery level in raw units, 0 = unknown
const char * OmReaderMetadata(OmReaderHandle reader, int *deviceId, unsigned int *sessionId)
Read the device id, session id and metadata of the binary file.
Temperature sensor reading in milli-centigrade.
int OmReaderNextBlock(OmReaderHandle reader)
Reads the next block of data from the binary file.
int OmGetAccelerometer(int deviceId, int *x, int *y, int *z)
Gets the specified device's current accelerometer values.
void OmReaderClose(OmReaderHandle reader)
Closes the specified reader handle.
int OmReaderGetValue(OmReaderHandle reader, OM_READER_VALUE_TYPE valueType)
Returns a specific value type from the buffer read by OmReaderNextBlock().
int OmSetLed(int deviceId, OM_LED_STATE ledState)
Sets the specified device's LED colour.
int OmReaderDataBlockSeek(OmReaderHandle reader, int dataBlockNumber)
Seeks the file reader to the specified data block.
unsigned char samplingRate
@36 +1 Sampling rate
unsigned int loggingCapacity
@21 +4 Preset maximum number of samples to collect, 0 = unlimited
int OmGetDevicePort(int deviceId, char *portBuffer)
Return the path to specified device's communication port.
Axis index for Mag-X (-Y and -Z follow), AX6(GAM)=6, not-present=-1.
int OmGetEcc(int deviceId)
Gets the error-correcting code flag for the specified device.
int OmWaitForDownload(int deviceId, OM_DOWNLOAD_STATUS *downloadStatus, int *downloadValue)
This function waits for the specified device's asynchronous download to finish.
int OmBeginDownloading(int deviceId, int dataOffsetBlocks, int dataLengthBlocks, const char *destinationFile)
Begin downloading the data from the current device.
int OmQueryDownload(int deviceId, OM_DOWNLOAD_STATUS *downloadStatus, int *downloadValue)
This function queries the status of the specified device's asynchronous download.
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.
int OmSetAccelConfig(int deviceId, int rate, int range)
Sets the specified device's accelerometer configuration to be used at the next recording session.
unsigned int lastChangeTime
@37 +4 Last change metadata time
int OmGetVersion(int deviceId, int *firmwareVersion, int *hardwareVersion)
Returns the firmware and hardware versions of the specified device.
int OmGetBatteryLevel(int deviceId)
Queries the specified device for the current battery charging level.
Axis index for Accel-X (-Y and -Z follow), AX3=0, AX6(A)=0, AX6(GA/GAM)=3, not-present=-1.
Data download failed with an error (the value parameter to OmDownloadCallback indicates a diagnostic ...
Axis index for Gyro-X (-Y and -Z follow), AX6(GA/GAM)=0, not-present=-1.
int OmGetMaxSamples(int deviceId, int *value)
Queries the specified device's 'maximum sample' value.
int OmGetSessionId(int deviceId, unsigned int *sessionId)
Queries the specified device's session identifier.
int OmGetAccelConfig(int deviceId, int *rate, int *range)
Queries the specified device's accelerometer configuration.
unsigned char sampleRate
@24 +1 Sample rate code, (3200/(1<<(15-(rate & 0x0f)))) Hz
int OmSetDownloadChunkCallback(OmDownloadChunkCallback downloadChunkCallback, void *reference)
Sets the chunk callback function that is called when a new download chunk is received.
void(* OmLogCallback)(void *, const char *)
Log callback function type.
OM_READER_HEADER_PACKET * OmReaderRawHeaderPacket(OmReaderHandle reader)
Accesses the contents of a raw header packet.
int OmSetTime(int deviceId, OM_DATETIME time)
Sets the specified device's internal real time clock.
void logCallback(void *reference, const char *message)
OM_DATETIME timestamp
@14 +4 Last reported RTC value, 0 = unknown
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.
unsigned int sessionId
@ 7 +4 Unique session identifier
Scaling: number of units for 1uT: AX6=16.
unsigned short packetHeader
@ 0 +2 ASCII "MD", little-endian (0x444D)
int OmSetLock(int deviceId, unsigned short code)
Sets the lock code for the device when it is connected.
OM_DATETIME OmReaderTimestamp(OmReaderHandle reader, int index, unsigned short *fractional)
Determines the timestamp of the specified sample in the buffer read by OmReaderNextBlock().
int OmGetLastConfigTime(int deviceId, OM_DATETIME *time)
Returns the date and time that the specified device was last configured.
Data download progress (the value parameter to OmDownloadCallback indicates progress percentage)
int OmGetDataFilename(int deviceId, char *filenameBuffer)
Return the path to the data file for the specified device.
int OmShutdown(void)
Shuts down the Open Movement API.
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...
unsigned short reserved2
@11 +2 (2 bytes reserved)
int OmReaderDataBlockPosition(OmReaderHandle reader)
Return the current block index of the reader.
All blocks on the NAND flash memory are cleared, the file-system is cleanly re-created,...
int OmGetDeviceSerial(int deviceId, char *serialBuffer)
Return the full USB serial string identity for the specified device.
OmReaderHandle OmReaderOpen(const char *binaryFilename)
Opens a binary data file for reading.
int OmGetTime(int deviceId, OM_DATETIME *time)
Queries the specified device's internal real time clock.
signed short timeZone
@42 +2 Time Zone offset from UTC (in minutes), 0xffff = -1 = unknown
int OmGetDelays(int deviceId, OM_DATETIME *startTime, OM_DATETIME *stopTime)
Gets the specified device's delayed activation start and stop times.
Automatic device-controlled LED to indicate state (default).
int OmSetLogCallback(OmLogCallback logCallback, void *reference)
Sets the callback function that is called whenever an API log message is written.
OM_LED_STATE
Enumeration of LED colours.
int OmSelfTest(int deviceId)
Performs a firmware-specific self-test on the specified device (e.g.
int OmGetDevicePath(int deviceId, char *pathBuffer)
Return the path to specified device's filesystem.
int OmGetMetadata(int deviceId, char *metadata)
Gets the contents of the specified device's metadata scratch buffer.
int OmSetLogStream(int fd)
Sets the stream to use for log messages.
unsigned int sequenceId
@10 +4 Sequence counter, each packet has a new number (reset if restarted)
int OmUnlock(int deviceId, unsigned short code)
Sets the lock code for the device when it is connected.
unsigned short temperature
@20 +2 Last recorded temperature sensor value in raw units, 0 = none
signed short timestampOffset
@26 +2 Relative sample index from the start of the buffer where the whole-second timestamp is valid
int OmGetDeviceIds(int *deviceIds, int maxDevices)
Obtains the device IDs of all connected devices.
void * OmReaderHandle
Handle to a reader object.
unsigned char reserved1
@ 4 +1 (1 byte reserved)
#define OM_METADATA_SIZE
The number of bytes of metadata scratch area on the device.
unsigned char numAxesBPS
@25 +1 0x32 (top nibble: number of axes = 3; bottom nibble: packing format - 2 = 3x 16-bit signed,...
OM_READER_VALUE_TYPE
Reader value indexes for OmReaderGetValue() function.
int OmGetDataFileSize(int deviceId)
Return the data file size of the specified device.
unsigned int sessionId
@ 6 +4 Unique session identifier, 0 = unknown
Data download was cancelled cleanly.
int OmSetDownloadCallback(OmDownloadCallback downloadCallback, void *reference)
Sets the callback function that is called for download progress, completion, cancellation,...
OM_DOWNLOAD_STATUS
Download states used in the OmDownloadCallback handler.
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.
Number of axes per sample.
int OmStartup(int version)
Initializes the Open Movement API.
short * OmReaderBuffer(OmReaderHandle reader)
Obtains a pointer to the buffer of samples read, and unpacked, by OmReaderNextBlock().
unsigned short packetHeader
@ 0 +2 ASCII "AX", little-endian (0x5841)
int OmSetEcc(int deviceId, int state)
Sets the error-correcting code flag for the specified device.
unsigned char firmwareRevision
@41 +1 Firmware revision number
OM_READER_DATA_PACKET * OmReaderRawDataPacket(OmReaderHandle reader)
Accesses the contents of a raw data packet.
Data file is removed and a new one created with the current metadata.
unsigned short packetLength
@ 2 +2 Packet length (508 bytes, with header (4) = 512 bytes total)
int OmEraseDataAndCommit(int deviceId, OM_ERASE_LEVEL eraseLevel)
Erases the specified device storage and commits the metadata and settings.
Raw light sensor reading.
unsigned short light
@18 +2 Last recorded light sensor value in raw units, 0 = none
void(* OmDownloadChunkCallback)(void *, int, void *, int, int)
Download chunk callback function type.
OM_DEVICE_STATUS
Device states used in the OmDeviceCallback handler.
void(* OmDownloadCallback)(void *, int, OM_DOWNLOAD_STATUS, int)
Download update callback function type.
unsigned short deviceId
@ 5 +2 Device identifier (low 16-bits)