WVR_GetTrackerDeviceName

WVR_EXPORT WVR_Result WVR_GetTrackerDeviceName(WVR_TrackerId trackerId, uint32_t * nameSize, char * deviceName)

Function to get device name of tracker device.

Version
API Level 12
Parameters
  • trackerId: Indicates what id of the tracker device. (Refer to WVR_TrackerId.)
  • nameSize: Ouput name size of tracker device as the buffer size. First, set nullptr to parameter deviceName to get nameSize fisrt. Then use this obtained nameSize to create char* type variable. Finally, get device name by calling this function again with obtained nameSize (MUST be the number obtained from first calling) and created char* type variable (MUST NOT be nullptr).
  • deviceName: Ouput device name of tracker device.
Return Value
  • WVR_Success: get device name of tracker device successfully.

How to use

Here is an example for the function:

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

bool gRunningTR = false;
  1. Start tracker feature first if it has not been started yet. (See also WVR Supported Features)
if (WVR_GetSupportedFeatures() & WVR_SupportedFeature_Tracker) { // the tracker feature is supported or not
    WVR_Result res = WVR_StartTracker();
    if (res == WVR_Success) gRunningTR = true;
}
  1. Use function WVR_GetTrackerDeviceName to get the device name of connected tracker device.
if (gRunningTR && WVR_IsTrackerConnected(WVR_TrackerId_0)) {
    // First call function with third parameter as nullptr to get name size (for buffer size of device name).
    uint32_t nameSize = 0;
    WVR_Result res = WVR_GetTrackerDeviceName(WVR_TrackerId_0, &nameSize, nullptr);
    LOGI("WVR_GetTrackerDeviceName, TrackerId(%d), result(%d), name_size(%d)", WVR_TrackerId_0, res, nameSize);

    // Ceate a char array type variable with obtained name size
    char devName[nameSize];

    // Secondly call function with obtained name size and char array type variable to get device name.
    res = WVR_GetTrackerDeviceName(WVR_TrackerId_0, &nameSize, devName);
    LOGI("WVR_GetTrackerDeviceName, TrackerId(%d), result(%d), name_size(%d), %s", WVR_TrackerId_0, res, nameSize, devName);
}