Synchroni SDK is the software development kit for developers to access OYMotion Synchroni products.
Application will obtain bluetooth permission by itself.
dependencies {
implementation files('../sdk/sensor.jar')
}
import com.sensor.*
request bluetooth permissions
//MainActivity.kt
PermissionX.init(this)
.permissions(permissions.asList())
.request { allGranted, grantedList, deniedList ->
if (allGranted) {
//setup scan delegate and scan
SensorController.getInstance().startScan(6000);
if (SensorController.getInstance().delegate == null){
SensorController.getInstance().delegate =
SensorController.SensorControllerDelegate { bleDevices ->
}
}
}
}
SensorController.getInstance().startScan(periodInMS);
//returns array of BLEDevice
SensorController.SensorControllerDelegate { bleDevices ->
for (device in bleDevices) {
if (!(device.name.startsWith("SYNC") || device.name.startsWith("OB"))) continue
Log.d("DEMO", "found device: " + device.name);
val sensor = SensorController.getInstance().getSensor(device.mac);
}
}
SensorController.getInstance().stopScan();
SensorProfile.connect()
SensorProfile.disconnect()
SensorProfile.deviceState;
Please send command in 'BLEState.ready'
public enum State {Disconnected, Connecting, Connected, Ready, Disconnecting, Invalid}
fun onStateChange(profile: SensorProfile, newState: BLEDevice.State) {
Log.d("DEMO",
"device : " + profile.device.name + " => " + newState.name
)
}
SensorProfile.initAll(PACKAGE_COUNT, timeoutInMS: TIMEOUT)
For start data transfer, use void startDataNotification(Callback cb)
to start. Process data in onSensorNotifyData.
SensorProfile.startDataNotification()
override fun onSensorNotifyData(profile: SensorProfile, rawData: SensorData) {
Log.d("DEMO",
profile.device.name + " got data type: " + rawData.dataType + " | " + rawData.channelSamples[0][0].sampleIndex
)
if (rawData.dataType == SensorData.NTF_EEG){
}
}
data type:
typedef NS_ENUM(NSInteger, NotifyDataType) {
NTF_ACC_DATA,
NTF_GYO_DATA,
NTF_EEG,
NTF_ECG,
NTF_BRTH,
};
sensor.stopDataNotification()