【问题标题】:Write data to microchip rn4870 vie ble将数据写入微芯片 rn4870 vie ble
【发布时间】:2020-11-29 09:36:54
【问题描述】:

我正在使用微芯片 rn4780。
我成功连接到设备,但是当我尝试向它发送数据(2 个字节)时,
我没有得到回应(它应该运行一些马达)。
我认为问题在于我正在使用的特性,但我不确定。 这是我的代码

override fun onServicesDiscovered(gatt: BluetoothGatt?, status: Int) {
        super.onServicesDiscovered(gatt, status)
        for (service in gatt!!.services){
            Log.d(TAG, "Service: " + service.uuid.toString())
            for (char in service.characteristics) {
                Log.d(TAG, "Char: " + char.uuid.toString())
                if(char.uuid.toString() == "49535343-8841-43f4-a8d4-ecbe34729bb3") {
                    Log.d(TAG, "Try to write")
                    char.value = byteArrayOf(0x39, 0x31)
                    gatt!!.writeCharacteristic(char)
                    Log.d(TAG, "Finish to write")
                }
            }
        }
    }

我尝试使用 google play 中的其他应用程序,但只有一个有效,它称为“lightblue”。
From that screen, it worked perfect (I send 39 and then 31 in hex)
From that screen it doesn't work, for each characteristic, I have tried

有一个微芯片指南,但我不明白他们在做什么不同:
https://microchipdeveloper.com/wireless:ble-mchp-transparent-uart-service

顺便说一下,我用flutter试过了,还是不行,所以如果有flutter的解决方案就更好了。

【问题讨论】:

  • 请注意,您可能只有一项未完成的 GATT 操作。等待回调,直到执行下一个。
  • 我只做一个操作,首先我等待它会连接,然后我等到我得到服务我只做一个操作,首先我等待它会连接,然后我等到我得到服务,然后只是运行它们并写入某些特征。有什么我想念的吗?
  • 如果该 uuid 有多个特征,您将在第一个完成之前使用该代码进行多次写入。
  • 那个uuid只有一个特征
  • 您可以尝试将无响应写入作为写入类型?

标签: android android-studio flutter bluetooth-lowenergy microchip


【解决方案1】:

我发现了问题,我在应用程序上使用了微芯片页面,它在我按摩前后发送了一些字节。 我通过查看应用程序上的日志文件来弄清楚。

【讨论】:

  • “我在应用程序上使用的微芯片页面”是什么意思? PS.:如果这解决了您的问题,请注明您的答案为已接受。
  • 我从那里发送了我需要的消息:i.stack.imgur.com/KNzt0.jpg screen,然后我查看了日志文件,发现应用程序在我的推荐中添加了一些字节。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-16
  • 2010-10-20
  • 2014-05-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多