This is proxy software for converting protocol of GrayBlue data BLE(Bluetooth smart Gatt) to websocket.
You can receive notified quaternion on UnityEditor with this app.
This makes you enable to do test play with GrayBlue devices on Unity Editor. You do not need to wait building project.
This set up http server on http://127.0.0.1:12345
and wait some client connections.
When a client order BLE operation (like scan or connection), a server(this) call Windows.Devices.Bluetooth
API and return result of API.
A server(this) and clients communicate by Json message on websocket prottocol.
All json in this app has type
and content
like this.
{
"type" : "XXX", /*names of type*/
"content" : {
/* some json content */
}
}
If you parse or create Json message, you need to know type
and their struct of content
.
Clients order some BLE operation (like a scan, connect and disconnect). It express as Method.
Example.
-
Scan
{ "type" : "Method", "content" : { "method_name" : "Scan", "method_param" : "" } }
-
Connect
{ "type" : "Method", "content" : { "method_name" : "Connect", "method_param" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02" } }
Response of BLE operation (like a scan, connect). It express as Result.
Example.
-
Scan
{ "type" : "Result", "content" : { "method" : { "method_name" : "Scan", "method_param" : "" }, "result" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02" } }
-
Connect
{ "type" : "Result", "content" : { "method" : { "method_name" : "Connect", "method_param" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02" }, "result" : "True" // if connect failed "False" } }
A server notify BLE device state when they are changed. It express as DeviceStateChange.
-
Lost
{ "type" : "DeviceStateChange", "content" : { "device_id" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02", "device_state" : "Lost" } }
A server notify 9-DOF sensor vlaue update from GrayBlue. It express as NotifyIMU.
-
IMU
{ "type" : "NotifyIMU", "content" : { "device_id" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02", "acc" : { "x" : 0.0 , "y" : 0.0, "z" : 1.0 }, "gyro" : { "x" : 0.0 , "y" : 0.0, "z" : 0.0 }, "mag" : { "x" : 0.0 , "y" : 0.0, "z" : 0.0 }, "quat" : { "x" : 0.0 , "y" : 0.0, "z" : 0.0, "w" : 1.0 }, } }
A server notify M5Stack-Gray button events. It express as NotifyButton.
-
Button Press
{ "type" : "NotifyButton", "content" : { "device_id" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02", "button" : "A", "press" : True, "time" : 0.0, } }
-
Button Release
{ "type" : "NotifyButton", "content" : { "device_id" : "BluetoothLE#BluetoothLE98:5f:d3:3a:e8:3c-84:0d:8e:3d:32:02", "button" : "A", "press" : False, "time" : 1.0, } }
.Net Core 3.0.0-preview4-27615-11
-
System.Reactive
- https://github.com/dotnet/reactive
- LICENSE: Apache-2.0
- version: 4.1.5
-
Newtonsoft.Json
- https://www.newtonsoft.com/json
- LICENSE: MIT
- version: 12.0.2
-
System.Net.WebSockets
- https://www.nuget.org/packages/System.Net.WebSockets/4.3.0
- LICENSE: MS-.NET-Library License
- version: 4.3.0