设备端发送的蓝牙信息,在面板端怎么接收到用那个api

小程序开发相关产品技术讨论,包括面板、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
liao12345
Posts: 14

  • Tuya MiniApp Tools 版本信息:关于中查看

    • App 应用版本信息: 设置-关于中进行查看~

    • @ray-js/ray, @ray-js/panel-sdk的版本(如使用ray开发)在package.json查看~

    • 移动设备信息:手机型号及系统

    • 相关代码:可复现该问题的代码内容

    • 日志信息:错误日志或 IDE 运行日志等~

    • 问题描述(复现步骤): 是Ray 开发的 用的是门锁 蓝牙模板
      const getLatestLogAsync2 = async () => {
      console.log('getLatestLogAsync2')
      ty.device.publishBLETransparentData({
      deviceId:devInfo.devId,
      data:'0x01',
      success: (res) => {
      console.log(888,res)
      setObjs(JSON.stringify(res))
      // subscribeBLETransparentDataReport()
      },
      fail: (err) => {
      console.log(23,err)
      },
      })
      }

      // 开始监听返回数、


      const subscribeBLETransparentDataReport = () => {
      ty.device.subscribeBLETransparentDataReport({
      deviceId:devInfo.devId,
      success: (res) => {
      console.log('订阅成功', res);
      setObjs(JSON.stringify(res))
      ty.device.unsubscribeBLETransparentDataReport({
      deviceId:devInfo.devId,
      success: (res) => {
      console.log('取消订阅成功', res);
      },
      fail: (err) => {
      console.log('取消订阅失败', err);
      }
      })
      }
      })
      }

    • 预期结果:通过 ty.device.subscribeBLETransparentDataReport 能监听到设备端蓝牙发送的内容

    • 实际结果:返回undifined

Last edited by liao12345 on 2024年 Sep 3日 10:01, edited 1 time in total.

Tags:
liao12345
Posts: 14

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

const getLatestLogAsync2 = async () => {
console.log('getLatestLogAsync2')
ty.device.publishBLETransparentData({
deviceId:devInfo.devId,
data:'0x01',
success: (res) => {
console.log(888,res)
setObjs(JSON.stringify(res))
// subscribeBLETransparentDataReport()
},
fail: (err) => {
console.log(23,err)
},
})
}

// 开始监听返回数、


const subscribeBLETransparentDataReport = () => {
ty.device.subscribeBLETransparentDataReport({
deviceId:devInfo.devId,
success: (res) => {
console.log('订阅成功', res);
setObjs(JSON.stringify(res))
ty.device.unsubscribeBLETransparentDataReport({
deviceId:devInfo.devId,
success: (res) => {
console.log('取消订阅成功', res);
},
fail: (err) => {
console.log('取消订阅失败', err);
}
})
}
})
}

不是dp,就是通过publishBLETransparentData发送蓝牙数据,然后 设备端会有数据返回,我要怎么接收到设备端返回来的蓝牙数据

crisiron
Posts: 79

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

https://developer.tuya.com/cn/miniapp/d ... nfoupdated 监听ble数据可以试试这个方法, 文档描述看起来有点问题 我找人同步修改下

liao12345
Posts: 14

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

crisiron 2024年 Sep 3日 10:09

https://developer.tuya.com/cn/miniapp/d ... nfoupdated 监听ble数据可以试试这个方法, 文档描述看起来有点问题 我找人同步修改下

这个api 设备 dp 名字和设备名字更新时触发的回调函数 我现在发送蓝牙数据 不会触发这个api,而且我下发蓝牙内容,没有走dp,ty.device.publishBLETransparentData({
deviceId:devInfo.devId,
data:'0x01',})

onDeviceInfoUpdated 这个返回示例:{
"dps": {
"1": false,
"9": 0,
"38": "off",
"40": "relay",
"42": "",
"43": "",
"44": "invalid"
},
"deviceId": "vdevo167878067815995"
},我也用不到

crisiron
Posts: 79

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

onBLETransparentDataReport 可以尝试下这个方法 ;还不行的话 我们这边找个设备跑下

liao12345
Posts: 14

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

crisiron 2024年 Sep 3日 11:09

onBLETransparentDataReport 可以尝试下这个方法 ;还不行的话 我们这边找个设备跑下

还是没有的

crisiron
Posts: 79

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

好的 我们这边正在烧录设备 准备调试中,有进展会及时同步的

crisiron
Posts: 79

Re: 设备端发送的蓝牙信息,在面板端怎么接收到用那个api

步骤是先注册:subscribeBLETransparentDataReport, 再监听:onBLETransparentDataReport

Post Reply