Skip to content

Verisense API Structure

JongChern edited this page Dec 21, 2021 · 1 revision

There are five main interfaces/abstract classes

  • VerisenseDevice
  • ISensor
  • IVersenseBLEManager
  • IVerisenseBLE
  • ICloudManager

The Interfaces and Abstract class above have been implemented by e.g. the following classes

  • S3CloudManager
  • SensorGSR, SensorLIS2DW12, SensorLSM6DS3
  • VerisenseBLEDevice
  • VerisenseBLEManager

The important thing to take note are the EventHandlers

  • BLEManagerEvent
  • CloudManagerEvent
  • ShimmerBLEEvent

IVerisenseBLEManager

This interface determines how Bluetooth scanning and pairing will be done. In the example this interface is implemented by VerisenseBLEManager. Key events to take note off are

BLEManagerEvent.BLEAdapterEvent.ScanCompleted
BLEManagerEvent.BLEAdapterEvent.DevicePaired

Note in the example on the app layer the Verisense Device with the largest RSS will be selected for pairing.

IVerisenseBLE

This interface determines how communication with the Verisense sensor will be conducted over Bluetooth Low Energy. In the example this interface is implemented by VerisenseBLEDevice. Key events to take note off are

//below signals the succesful completion of the syncing process, where logged data from the verisense sensor is transmitted back to the application
VerisenseBLEEvent.SyncLoggedDataComplete
//when the bluetooth state of the device changes the following event is called
VerisenseBLEEvent.StateChange
//when there is a new sensor data packet received from the physical Verisense device
VerisenseBLEEvent.NewDataPacket
             

ICloudManager

This interface determines how bin files will be uploaded to the S3 cloud. Bin files are raw sensor data which have been downloaded/synced between the app and the verisense sensor. In the example this interface is implemented by S3CloudManager. Key event to take note off are

CloudManagerEvent.CloudEvent.UploadSuccessful

ISensor

This interface determines how the individual sensors on the Verisense device can be configured. The idea will be to create a 'clone' of the verisense device, update the sensor/setting within the clone. Generate the operation config bytes and transmit said bytes to the physical Verisense device.

//create a clone, new settings are applied to the clone
VerisenseBLEDevice cloneDevice = new VerisenseBLEDevice(verisenseBLEDevice);
var sensor = cloneDevice.GetSensor(SensorLIS2DW12.SensorName);
((SensorLIS2DW12)sensor).SetAccelEnabled(true);
((SensorLIS2DW12)sensor).SetAccelRate(SensorLIS2DW12.LowPerformanceAccelSamplingRate.Freq_25Hz);
sensor = cloneDevice.GetSensor(SensorGSR.SensorName);
((SensorGSR)sensor).SetGSREnabled(false);
((SensorGSR)sensor).SetBattEnabled(false);
sensor = cloneDevice.GetSensor(SensorLSM6DS3.SensorName);
((SensorLSM6DS3)sensor).SetAccelEnabled(false);
((SensorLSM6DS3)sensor).SetGyroEnabled(false);
//once the clone is updated with the new settings we generate the new configuration bytes to be sent over Bluetooth
byte[] opconfigBytes = cloneDevice.GenerateConfigurationBytes();
verisenseBLEDevice.ExecuteRequest(RequestType.WriteOperationalConfig, opconfigBytes);
Clone this wiki locally