如何使用evothing从(Contec)Pulse Oximeter读取和解析数据?

时间:2015-08-31 10:01:57

标签: cordova

我想开发一个移动应用程序,通过蓝牙使用evothings(或phonegap)连接读取和解析Contec Pulse Oximeter的测量数据 我可以连接,发现和读取静态数据(设备名称,地址......),但我无法读取测量结果。 我应该使用什么服务和特色?我应该写描述符来获得测量结果吗?

发现结果是(evothings):

protected $table = 'myclients'

Phonegap(BLE插件)

[
    {
        "type":0,"uuid":"00001800-0000-1000-8000-00805f9b34fb",
        "handle":1,
        "characteristics":[
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a00-0000-1000-8000-00805f9b34fb",
                "handle":4,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a01-0000-1000-8000-00805f9b34fb",
                "handle":5,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a04-0000-1000-8000-00805f9b34fb",
                "handle":6,
                "descriptors":[]
            }
        ]
    },

    {
        "type":0,"uuid":"0000180a-0000-1000-8000-00805f9b34fb",
        "handle":2,
        "characteristics":[
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a29-0000-1000-8000-00805f9b34fb",
                "handle":7,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a24-0000-1000-8000-00805f9b34fb",
                "handle":8,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a25-0000-1000-8000-00805f9b34fb",
                "handle":9,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a27-0000-1000-8000-00805f9b34fb",
                "handle":10,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a26-0000-1000-8000-00805f9b34fb",
                "handle":11,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a28-0000-1000-8000-00805f9b34fb",
                "handle":12,"descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a23-0000-1000-8000-00805f9b34fb",
                "handle":13,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":2,
                "uuid":"00002a2a-0000-1000-8000-00805f9b34fb",
                "handle":14,
                "descriptors":[]
            }
        ]
    },

    {
        "type":0,
        "uuid":"49535343-fe7d-4ae5-8fa9-9fafd205e455",
        "handle":3,
        "characteristics":[
            {
                "permissions":0,
                "writeType":2,
                "properties":10,
                "uuid":"49535343-6daa-4d02-abf6-19569aca69fe",
                "handle":15,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":24,
                "uuid":"49535343-aca3-481c-91ec-d85e28a60318",
                "handle":16,
                "descriptors":[
                    {
                        "permissions":0,
                        "uuid":"00002902-0000-1000-8000-00805f9b34fb",
                        "handle":20
                    }
                ]
            },
            {
                "permissions":0,
                "writeType":1,
                "properties":30,
                "uuid":"49535343-1e4d-4bd9-ba61-23c647249616",
                "handle":17,
                "descriptors":[
                    {
                        "permissions":0,
                        "uuid":"00002902-0000-1000-8000-00805f9b34fb",
                        "handle":21
                    }
                ]
            },
            {
                "permissions":0,
                "writeType":1,
                "properties":12,
                "uuid":"49535343-8841-43f4-a8d4-ecbe34729bb3",
                "handle":18,
                "descriptors":[]
            },
            {
                "permissions":0,
                "writeType":2,
                "properties":24,
                "uuid":"49535343-026e-3a9b-954c-97daef17e26e",
                "handle":19,
                "descriptors":[
                    {
                        "permissions":0,
                        "uuid":"00002902-0000-1000-8000-00805f9b34fb",
                        "handle":22
                    }
                ]
            }
        ]
    }
]

我的JS代码

{
    "address":"8C:DE:52:80:B5:24",
    "status":"discovered",
    "services":[
        {"characteristics":
            [
                {"descriptors":[],"characteristicUuid":"2a00","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a01","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a04","properties":{"read":true}}
            ],
            "serviceUuid":"1800"
        },
        {"characteristics":
            [
                {"descriptors":[],"characteristicUuid":"2a29","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a24","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a25","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a27","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a26","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a28","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a23","properties":{"read":true}},
                {"descriptors":[],"characteristicUuid":"2a2a","properties":{"read":true}}
            ],
            "serviceUuid":"180a"
        },
        {"characteristics":
            [
                {
                    "descriptors":[],
                    "characteristicUuid":"49535343-6daa-4d02-abf6-19569aca69fe",
                    "properties":{"write":true,"read":true}
                },

                {
                    "descriptors":[{"descriptorUuid":"2902"}],
                    "characteristicUuid":"49535343-aca3-481c-91ec-d85e28a60318",
                    "properties":{"write":true,"notify":true}
                },

                {
                    "descriptors":[{"descriptorUuid":"2902"}],
                    "characteristicUuid":"49535343-1e4d-4bd9-ba61-23c647249616",
                    "properties":{"write":true,"writeWithoutResponse":true,"read":true,"notify":true}
                },

                {
                    "descriptors":[],
                    "characteristicUuid":"49535343-8841-43f4-a8d4-ecbe34729bb3",
                    "properties":{"write":true,"writeWithoutResponse":true}
                },

                {
                    "descriptors":[{"descriptorUuid":"2902"}],
                    "characteristicUuid":"49535343-026e-3a9b-954c-97daef17e26e",
                    "properties":{"write":true,"notify":true}
                }
            ],
            "serviceUuid":"49535343-fe7d-4ae5-8fa9-9fafd205e455"
        }
    ],
    "name":"SpO2081127"
}

4 个答案:

答案 0 :(得分:1)

Contec血氧仪确实使用ISSC transparent service。那就是服务并不是特定的测定仪,它只是一种透明的服务。通过蓝牙LE公开串行连接。

您只需要使用2个特性:TX和RX:

TX:49535343-1E4D-4BD9-BA61-23C647249616

RX:49535343-8841-43F4-A8D4-ECBE34729BB3

您需要做的是:

  1. 打开TX特性的通知
  2. 将命令写入RX特性(WriteWithResponse)
  3. 您将收到有关TX特征的数据
  4. 例如,要打开实时数据流:

    1. 将以下9个字节写入RX特性:{0x7D,0x81,0xA1,0x80,0x80,0x80,0x80,0x80,0x80}。所有命令都是9个字节。
    2. 您将开始以60 Hz的频率接收TX特性数据。
    3. 有关如何解析数据的更多命令和信息,请参阅Albert Braun's Github project for the CMS50FW。该项目还包含PDF with the documentation of the protocol

答案 1 :(得分:0)

在调用characteristic.handlesapp.read时,您不能像ble.enableNotification函数那样对ble.descriptors进行硬编码。这些值可能会在您的程序运行之间发生变化,甚至更有可能在平台之间进行更改。

相反,您必须在ble.readAllServiceData回调中迭代服务及其特征,寻找具有所需UUID的特征,保存其句柄(通常在app.member中),并在app.read中使用它。

为了简化BLE编程中的这个(相当常见的)任务,我们有一个名为“easyble”的库,它建立在BLE插件之上。如果你愿意,可以使用它。

答案 2 :(得分:0)

我可以在你的链接示例中找到的唯一明显的错误是你没有检查描述符的UUID(这是不好的,因为可能有其他描述符而不是“2902”),但是如果您发布的发现结果之前保持不变,那不应该阻止这个特定的程序工作。

我现在记得有些设备要求您将某些值写入某些特征,以便开始测量,从而产生通知。例如,德州仪器SensorTag(链接)。

Google搜索您的服务UUID表示它名为“ISSC Proprietary Service”,并且似乎充当某种串行数据链接。不幸的是,我找不到任何英文文档。

如果使用此服务运行心率监测器,那么我怀疑您的问题变得更加复杂。

此时我记得我一直都很傻,而且没有抬起你正在使用的设备名称。 Contec Pulse Oximeter,最初构建,似乎使用a rather complex serial protocol设计用于RS232或USB连接。这解释了ISSC串行服务。不幸的是,它对我们没有多大帮助,因为我们仍然不知道该服务是如何运作的。

我也无法在互联网上找到任何使用BLE的Contec设备。您是否有用户手册或描述设备通信协议的任何文档?

答案 3 :(得分:0)

Bluebit类ActivityTransparent指示激活TX特性通知(UUID 49535343-1e4d-4bd9-ba61-23c647249616)应该让它开始发送数据。您可以尝试该特征,而不是其他任何一个。