C#_SDK_Quick star

C#_SDK_quick start

Where to download

Please check the below link to download

https://github.com/WITMOTION/WitBluetooth_BWT901BLE5_0arrow-up-right

What is BLE 5.0 protocol?

Bluetooth 5.0 protocol: It is the protocol used by WitMotion Bluetooth 5.0 sensors; the protocol stipulates that the sensor returns data packets beginning with 55, and the host computer sends data packets beginning with FF AA; Bluetooth 5.0 protocol: It is the protocol used by WitMotion Bluetooth

Routine Introduction

This routine introduces how to use C# to develop the upper computer to connect to the Bluetooth 5.0 protocol sensor, receive sensor data and communicate with the sensor; Before viewing this routine, please read the relevant sensor manual to understand the protocol used by the sensor and the basic functions of the sensor

Routine Diretory

The routine project directory is as follows

Dll: The dependent files of the project, please import these dlls into your project before running the project.

Form1:There is only one Form window in the routine, all logic codes are in the Form window file, and there are no other files

The BWT901BLE object represents the BWT901BLE device in the program, and you can communicate with the device through it; when searching for devices, call bluetoothManager.StartScan() to start searching; when opening the device, you need to specify the Bluetooth address of the Bluetooth sensor, and call BWT901BLE.Open() after specifying method

Close the search and call the bluetoothManager.StopScan() method

Receive the sensor data

Get data

The BWT901BLE object will automatically calculate the sensor data and save it on itself. The sensor data can be obtained through the BWT901BLE.GetDeviceData() method. BWT901BLE.GetDeviceData() needs to pass in a key to get sensor data. Please check the key that needs to be used in the routine, the key is stored in the WitSensorKey class

Record data

The data of the sensor can be obtained through the BWT901BLE object, but usually the host computer needs to record the data of the sensor. BWT901BLE has an OnRecord event that will notify you when the data should be recorded, and the OnRecord event can be realized when the device is turned on; and then through cooperation with BWT901BLE.GetDeviceData( ) method to record the data

Setting the sensor

The sensor can be operated by means of BWT901BLE

BWT901BLE.UnlockReg() Send unlock register command

BWT901BLE.AppliedCalibration() Send accelerometer calibration

BWT901BLE.StartFieldCalibration() Send start magnetic field calibration command

BWT901BLE.EndFieldCalibration() Send end magnetic field calibration command

BWT901BLE.SendProtocolData() send other commands

Accelerometer Clibration

Applied calibration of the sensor by calling the BWT901BLE.AppliedCalibration() method

Magnetic field calibration

Calibrate the magnetic field of the sensor by calling the BWT901BLE.StartFieldCalibration() method and the BWT901BLE.EndFieldCalibration() method

More

Pleaes reference to the sensor datasheet.

Read sensor register

The register of the sensor can be read through the BWT901BLE.SendReadReg() method, or the BWT901BLE.SendProtocolData() method can be used

After sending the read command, the register value will be saved in BWT901BLE, you need to get the register data through BWT901BLE.GetDeviceData()

BWT901BLE API

Method

Illustrate

Parameter introduction

Return value

void SetMacAddr(string macAddr)

Set the bluetooth address to open

macAddr:bluetooth address

void

void SetDeviceName(string DeviceName)

set device name

DeviceName:device name

void

void Open()

turn on the device

none

void

bool IsOpen()

Is the device turned on

none

返回是否打开打开:true关闭:false

void Close()

turn off the device

nones

void

void SendData(byte[] data, out byte[] returnData, bool isWaitReturn, int waitTime , int repetition)

send data

data: the data to be sent returnData: the data returned by the sensor isWaitReturn: Whether the sensor needs to return data waitTime: wait for the sensor to return data time, unit ms, default 100ms repetition: the number of times to repeat sending

void

void SendProtocolData(byte[] data)

send protocol data

data:data to send

void

void SendProtocolData(byte[] data, int waitTime)

Send data with protocol, and specify the waiting time

data:data to send

waitTime:waiting time

void

void SendReadReg(byte reg, int waitTime)

Send the command to read the register

reg:command to send

waitTime:waiting time

void

void UnlockReg()

unlock register

none

void

void SaveReg()

save register

none

void

void AppliedCalibration()

Accelerometer Calibration

none

void

void StartFieldCalibration()

Start Magnetic Field Calibration

none

void

void EndFieldCalibration()

End magnetic field calibration

none

void

void SetReturnRate(byte rate)

set return rate

rate:Return rate to be set

void

string GetDeviceName()

get device name

none

return device name

string GetDeviceData(string key)

Get Key value data

key:data key

return data value

英文说明

📎Bluetooth Protocol SDK Quick Guide.pdfarrow-up-right

Last updated