WVR_GetTrackerExtendedData

WVR_EXPORT int32_t* WVR_GetTrackerExtendedData(WVR_TrackerId trackerId, int32_t * validSize, uint64_t * timestamp = nullptr)

Function to get extended data of tracker device.

Remark
This API works only when supportsExtendedData (obtained by WVR_GetTrackerCapabilities) is true .
Version
API Level 8
Parameters
  • trackerId: Indicates what id of the tracker device. (Refer to WVR_TrackerId.)
  • validSize: Output the size to determine the valid length of data content. If validSize is less than or equal to 0, the data content from the returned address are meaningless.
  • timestamp: Output timestamp of tracker extended data. (API Level 12)
Return Value
  • int32_t*: The first address of data content. If the returned address is nullptr, the data content are meaningless.

How to use

Here is an example for the function:

  1. Header & global variables.
#include <wvr/wvr.h> // for enum WVR_SupportedFeature
#include <wvr/wvr_events.h>
#include <wvr/wvr_tracker.h>
#include <wvr/wvr_types.h>

bool gRunningTR = false;

// Global variables for device capabilities of WVR_TrackerId_0
WVR_TrackerCapabilities_t gCapabilitiesId0;
  1. Start tracker feature first if it has not been started yet. (See also WVR Supported Features)
    • And (Timing 1 - After starting tracker feature successfully) use function WVR_GetTrackerCapabilities to get tracker capabilities to check whether extended data feature (capability supportsExtendedData) is supported or not.
if (WVR_GetSupportedFeatures() & WVR_SupportedFeature_Tracker) { // the tracker feature is supported or not
    WVR_Result res = WVR_StartTracker();
    if (res == WVR_Success) gRunningTR = true;
}

// Timing 1: Update the tracker capabilities after WVR_StartTracker for the tracker device which has been connected before.
if (gRunningTR && WVR_IsTrackerConnected(WVR_TrackerId_0)) {
    WVR_Result ret = WVR_GetTrackerCapabilities(WVR_TrackerId_0, &gCapabilitiesId0);
    // Needs gCapabilitiesId0.supportsExtendedData
}
  1. (Timing 2 - When receiving event WVR_EventType_TrackerConnected) Use function WVR_GetTrackerCapabilities to get tracker capabilities to check whether extended data feature (capability supportsExtendedData) is supported or not.
void ProcessEvent() {
    WVR_Event_t event;
    while(WVR_PollEventQueue(&event)) {
        switch (event.common.type) {
            /* Timing 2: Update tracker capabilities when tracker device has just been connected.*/
            case WVR_EventType_TrackerConnected:
                {
                    if (gRunningTR && event.tracker.trackerId == WVR_TrackerId_0) {
                        WVR_Result ret = WVR_GetTrackerCapabilities(event.tracker.trackerId, &gCapabilitiesId0);
                        LOGI("TrackerId_%d, capabilities(ret: %d): %d, %d, %d, %d, %d, %d",
                            event.tracker.trackerId, ret,
                            gCapabilitiesId0.supportsOrientationTracking,
                            gCapabilitiesId0.supportsPositionTracking,
                            gCapabilitiesId0.supportsInputDevice,
                            gCapabilitiesId0.supportsHapticVibration,
                            gCapabilitiesId0.supportsBatteryLevel,
                            gCapabilitiesId0.supportsExtendedData);
                    }
                }
                break;
            default:
                break;
        }
    }
}
  1. Use function WVR_GetTrackerExtendedData to get extended data.
if (gRunningTR &&
    gCapabilitiesId0.supportsExtendedData &&
    WVR_IsTrackerConnected(WVR_TrackerId_0)) {
    int32_t validSize = 0;
    int32_t *exData = WVR_GetTrackerExtendedData(WVR_TrackerId_0, &validSize);
    if (exData != nullptr && validSize > 0) { // If exData != nullptr and valid size > 0, extended data are valid
         for (int i = 0; i < validSize; i++) {
             LOGI("WVR_GetTrackerExtendedData, id(%d), size(%d), exdata[%d]: %d", WVR_TrackerId_0, validSize, i, exData[i]);
         }
    }

}
  1. Use function WVR_GetTrackerExtendedData to get extended data with timestamp. (Supported at API Level 12 or later)
if (gRunningTR &&
    gCapabilitiesId0.supportsExtendedData &&
    WVR_IsTrackerConnected(WVR_TrackerId_0)) {
    int32_t validSize = 0;
    uint64_t timestamp = 0;
    int32_t *exData = WVR_GetTrackerExtendedData(WVR_TrackerId_0, &validSize, &timestamp);
    if (exData != nullptr && validSize > 0) { // If exData != nullptr and valid size > 0, extended data are valid
         for (int i = 0; i < validSize; i++) {
             LOGI("WVR_GetTrackerExtendedData, id(%d), size(%d), ts(%" PRId64 "), exdata[%d]: %d", WVR_TrackerId_0, validSize, timestamp, i, exData[i]);
         }
    }

}

Note

  1. This function works when capability supportsExtendedData of tracker device is true.
  2. If validSize is less than or equal to 0, the extended data are invalid.