Initialization of the Tire Tread SDK

Setting up the Callback-Functions

The app must provide functions that can be called by the Tire Tread SDK. Results are communicated to the app through these callbacks. The following functions must be provided.

Methode Description

callbackErrorHandler()

This function is called when communication with the Tread Server fails, such as download or upload errors.

callbackResultHandlerMetric()

This function is called when metric tread depth values are requested from the server and are available after a measurement.

callbackResultHandlerImperial()

This function is called when imperial (inch) tread depth values are requested from the server and are available after a measurement.

callbackResultHandlerError()

This function is called when errors occurs during the calculation of results on the Tread Server.

callbackUploadFinishedHandler()

The app is informed of the completion of the upload process.

callbackMeasureUploadSpeedHandler()

After the speed test is called, the results of the upload speed test are communicated to this function.

Handling of the the Tire ReturnValue

The Tire Tread SDK returns results to the calling functions through a ReturnValue. This class contains a result status as a Boolean variable and a message that provides an error hint in case of errors.

Set the Parameters and the CallBack Functions

This code block first creates a Parameters object and then fills this object with the default settings. It then sets the license ID, measurement system, and log file sending frequency using the stored values.

Next, the code sets up several callbacks, such as errorHandler(), resultHandlerImperial(), resultHandlerMetric(), resultHandlerError(), speedTestUploadHandler(), and uploadFinishedHandler(), using the methods setCallbackErrorHandler(), setCallbackResultHandlerImperial(), etc. These callbacks are used to handle both errors and results from the Tire Tread SDK. The code sets the context for the log file path using setContext() with the getBaseContext() method as the argument.

Finally, the Tire Tread SDK is initialised using the initSDK() method with parameters as the argument. The code then checks the success of the initialisation using the result.getSuccess() method and logs the result using the XLog class. The result of the initialisation process is then returned.

protected ReturnValue initTreadSDK() {
// SDK Parameter class
Parameters parameters = AppSettings.getSDKParameters();
// Parameters
parameters.setLicenseKey(AppSettings.licenseKey);
parameters.setMeasurementSystem(eMeasurementSystem.Metric);
parameters.setSendLogFileToApiFrequency(eSendLogFileToApiFrequency.Measurement);
// Callbacks
parameters.setCallbackErrorHandler(MainActivity::errorHandler);
parameters.setCallbackResultHandlerImperial(ResultActivity::resultHandlerImperial);
parameters.setCallbackResultHandlerMetric(ResultActivity::resultHandlerMetric);
parameters.setCallbackResultHandlerError(ResultActivity::resultHandlerError);
parameters.setCallbackMeasureUploadSpeedHandler(SettingsActivity::speedTestUploadHandler);
parameters.setCallbackRecordingFinishedHandler(RecordingActivity::recordingFinishedHandler);
parameters.setCallbackUploadFinishedHandler(RecordingActivity::uploadFinishedHandler);
// Context for log file path
parameters.setContext(getBaseContext());
// Transfer the settings to the TreadSDK
ReturnValue returnValue = TreadSDK.getInstance().initSDK(parameters);
if (returnValue.getSuccess()) ...

Configuration and Parameters

The SDK requires some essential parameters to be initialized before it can be used. The Parameters class contains all the necessary parameters required to initialize the Tire Tread SDK.

The following are the parameters included in the Parameters class:

licenseKey: This is the license key for the TreadSDK. It is a unique identifier for the SDK and is required for its proper functioning, you will receive it from your Anyline sales contact.

measurementSystem: This parameter specifies the measurement system to be used for measurements. The options available are metric and imperial. The result handler are called based on this setting.

sendLogFileToApiFrequency: This parameter defines the frequency at which log files will be sent to the API. The options available are measurement and never. Reference the the file eSendLogFileToApiFrequency.java.

measurementQuality: This parameter determines the quality of the measurement results. The options available are medium and high. Reference the file eMeasurementQuality.java.

context: This is the Android context, which is required for the proper functioning of the TreadSDK.

The 'appMode' parameter determines the operation mode of the Tire Tread SDK. It has two options: measurement and recorder. The measurement mode enables the Tire Tread SDK to send measurement data to the server, while the 'recorder' mode only records the data without transmitting it to the server.

callbackUploadFinishedHandler: This is a callback function that will be triggered when the upload of the measurement results is finished.

callbackResultHandlerMetric: This is a callback function that will be triggered when the measurement results in the metric system are available.

callbackResultHandlerImperial: This is a callback function that will be triggered when the measurement results in the imperial system are available.

callbackResultHandlerError: This is a callback function that is invoked when an error occurs during the measurement process. The error message is passed as an argument to the callback function. If this callback function is triggered, the other result callback functions callbackResultHandlerMetric and callbackResultHandlerImperial will not be executed.

callbackErrorHandler: This is a callback function that will be triggered when there is an error during the initialization, the checkServer()-or the uploadSpeedTest()-methode of the Tire Tread SDK.

callbackMeasureUploadSpeedHandler: This is a callback function that will be activated once the results of the measurement images upload speed test are available.

callbackRecordingFinishedHandler: This is a callback function that will be triggered when the recording of the measurement results is finished.

configTrafficLightMetric: This parameter contains the configurations for the traffic light system in the metric system.

configTrafficLightImperial: This parameter contains the configurations for the traffic light system in the imperial system.

Customizing the Traffic Light System Thresholds in Metric and Imperial Units

By setting the following threshold values, you can customize the traffic light system to fit your specific needs. The yellow color is automatically calculated as the range between the red and green thresholds.

ConfigTrafficLightMetric()

The ConfigTrafficLightMetric() class is used to set the threshold values for the traffic light system in metric units. The traffic light system is used to indicate the tire tread depth measurement results. The class contains two parameters:

thresholdResultMmRed: This parameter sets the threshold value for the red color in millimeters. The red color indicates that the tire tread depth is below the recommended level.

thresholdResultMmGreen: This parameter sets the threshold value for the green color in millimeters. The green color indicates that the tire tread depth is within the recommended level.

ConfigTrafficLightImperial()

The ConfigTrafficLightImperial() class is used to define the thresholds for the traffic light system in imperial units. The ConfigTrafficLightImperial class has two parameters:

thresholdResultInchRed: This parameter defines the threshold for the red color in inches. If the measurement result is below this threshold, the traffic light will turn red.

thresholdResultInchGreen: This parameter defines the threshold for the green color in inches. If the measurement result is above this threshold, the traffic light will turn green.

Check the API connection and status

The public method ReturnValue checkApiStatus() checks the status of the cloud server. The .getMessage() function provides an error message in the event of a failed connection. It is essential to call the initSDK() method prior to invoking this function. If the license key is not set, the function will fail with a corresponding error message.

final ReturnValue returnValue = TreadSDK.getInstance().checkApiStatus();
if (!returnValue.getSuccess())
{
   ...
}