Skip to content

Latest commit

 

History

History
192 lines (149 loc) · 4.6 KB

README.md

File metadata and controls

192 lines (149 loc) · 4.6 KB

GrayBlue_WinProxy

This is proxy software for converting protocol of GrayBlue data BLE(Bluetooth smart Gatt) to websocket.

Demo

You can receive notified quaternion on UnityEditor with this app.

Description

notifies 9-DOF motion data.

This makes you enable to do test play with GrayBlue devices on Unity Editor. You do not need to wait building project.

Websocket

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.

Json

0. root

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.

1. Method

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"
        }
    }

2. Result

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"
        }
    }

3. DeviceStateChange

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"
        }
    }

4. NotifyIMU

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 },
        }
    }

5. NotifyButton

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,
        }
    }

Environment

.Net Core 3.0.0-preview4-27615-11

Library

Licence

MIT

Author

@naninunenoy