uni-app 有偿求助

qq1332783374 · 3 天前 · 103 次点击

关于 uni-app 低功耗蓝牙的问题

  • 设备信息
    • 手机:红米 Note12
    • 系统:安卓 13
    • MIUI:14.0.10
    • 对接设备:JDY-16 蓝牙 4.2 模块
  • 文档地址: https://uniapp.dcloud.net.cn/api/system/ble.html
  • 调用的 API:uni.notifyBLECharacteristicValueChange
  • 问题描述:在小程序可以正常使用,在安卓上报 10008 错误码
  • 期望:可以在安卓上正常接受数据
  • 备注:手机已经给 App 开启蓝牙和定位权限。有遇到相同问题的或有解决思路的大佬,可以加 wx1332783374

输出日志和配置

小程序日志信息:

12:26:06.842 点击了蓝牙 3C:A5:51:9B:2E:69 at pages/bleconnction/bleconnction.vue:116
12:26:07.581 蓝牙连接成功! at pages/bleconnction/bleconnction.vue:129
12:26:09.101 getBLEDeviceServices success {services: [ ⁠...⁠ ], errCode: 0, errno: 0, errMsg: "getBLEDeviceServices:ok"} at pages/bleconnction/bleconnction.vue:141
12:26:09.225 获取服务 UUID 成功! 0000FFE0-0000-1000-8000-00805F9B34FB at pages/bleconnction/bleconnction.vue:142
12:26:11.119 获取特征 UUID 成功! at pages/bleconnction/bleconnction.vue:151
12:26:11.120 getBLEDeviceCharacteristics {characteristics: [ ⁠...⁠ ], errCode: 0, errno: 0, errMsg: "getBLEDeviceCharacteristics:ok"} at pages/bleconnction/bleconnction.vue:152
12:26:11.120 notifyBLECharacteristicValueChange success {errno: 0, errCode: 0, errMsg: "notifyBLECharacteristicValueChange:ok"} at pages/bleconnction/bleconnction.vue:164
12:26:12.693 这是共享的数据 at pages/bleReciveSend/bleReciveSend.vue:80
12:26:12.739 已经连接 at pages/bleReciveSend/bleReciveSend.vue:128
12:26:12.739 A at pages/bleReciveSend/bleReciveSend.vue:141
12:26:12.740 执行了监听 at pages/bleReciveSend/bleReciveSend.vue:143
12:26:16.684 2f 2a 2a 2a 2a b5 da 30 30 32 d7 e9 2a 2a 2a 2a 2f 0d 0a b0 at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.730 /****µÚ002×é****/\r\n° at pages/bleReciveSend/bleReciveSend.vue:147
12:26:16.730 b2 d7 b0 be e0 c0 eb 30 39 31 20 6d 6d 0d 0a d7 ee b4 f3 d6 at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.730 ²×°¾àÀë091 mm\r\n×î´óÖ at pages/bleReciveSend/bleReciveSend.vue:147
12:26:16.730 b5 30 30 33 20 6d 6d 0d 0a d7 ee d0 a1 d6 b5 30 30 33 20 6d at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.732 µ003 mm\r\n×îСֵ003 m at pages/bleReciveSend/bleReciveSend.vue:147
12:26:16.732 6d 0d 0a c6 bd be f9 d6 b5 30 30 33 20 6d 6d 0d 0a b9 b2 b2 at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.732 m\r\nƽ¾ùÖµ003 mm\r\n¹²² at pages/bleReciveSend/bleReciveSend.vue:147
12:26:16.777 e2 c1 bf c1 cb 30 30 34 20 b8 f6 ca fd be dd 0d 0a 2f 2a 2a at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.777 âÁ¿ÁË004 ¸öÊý¾Ý\r\n/** at pages/bleReciveSend/bleReciveSend.vue:147
12:26:16.777 2a 2a 2a 2a 2a 2a bd e1 ca f8 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.777 ******½áÊø*********/ at pages/bleReciveSend/bleReciveSend.vue:147
12:26:16.777 0d 0a 0d 0a 0d 0a at pages/bleReciveSend/bleReciveSend.vue:146
12:26:16.777 \r\n\r\n\r\n at pages/bleReciveSend/bleReciveSend.vue:147

安卓日志信息:

12:34:16.960 点击了蓝牙,  3C:A5:51:9B:2E:69 at pages/bleconnction/bleconnction.vue:116
12:34:17.209 蓝牙连接成功! at pages/bleconnction/bleconnction.vue:129
12:34:18.754 getBLEDeviceServices success,  [Object] {"services":[{"uuid":"00001800-0000-1000-8000-00805F9B34FB","isPrimary":true},{"uuid":"0000...} at pages/bleconnction/bleconnction.vue:141
12:34:18.754 获取服务 UUID 成功!,  00001800-0000-1000-8000-00805F9B34FB at pages/bleconnction/bleconnction.vue:142
12:34:20.779 获取特征 UUID 成功! at pages/bleconnction/bleconnction.vue:151
12:34:20.779 getBLEDeviceCharacteristics,  [Object] {"characteristics":[{"uuid":"00002A00-0000-1000-8000-00805F9B34FB","properties":{"read":tru...} at pages/bleconnction/bleconnction.vue:152
12:34:20.800 notifyBLECharacteristicValueChange error,  [Object] {"errMsg":"notifyBLECharacteristicValueChange:fail no descriptor","code":10008}  at pages/bleconnction/bleconnction.vue:176

manifest.json 配置

{
    "name" : "blethooth_project",
    "appid" : "__UNI__7B141DE",
    "description" : "",
    "versionName" : "1.0.0",
    "versionCode" : "100",
    "transformPx" : false,
    /* 5+App 特有相关 */
    "app-plus" : {
        "usingComponents" : true,
        "nvueStyleCompiler" : "uni-app",
        "compilerVersion" : 3,
        "splashscreen" : {
            "alwaysShowBeforeRender" : true,
            "waiting" : true,
            "autoclose" : true,
            "delay" : 0
        },
        /* 模块配置 */
        "modules" : {
            "Bluetooth" : {},
            "Geolocation" : {}
        },
        /* 应用发布信息 */
        "distribute" : {
            /* android 打包配置 */
            "android" : {
                "permissions" : [
                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
                    "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",
                    "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
                    "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
                    "<uses-feature android:name=\"android.hardware.camera\"/>",
                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
					"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />",
					"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />",
					"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />",
					"<uses-permission android:name=\"android.permission.BLUETOOTH\" />",
					"<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\" />"
                ]
            },
            /* ios 打包配置 */
            "ios" : {},
            /* SDK 配置 */
            "sdkConfigs" : {
                "geolocation" : {
                    "system" : {
                        "__platform__" : [ "ios", "android" ]
                    }
                }
            }
        }
    },
    /* 快应用特有相关 */
    "quickapp" : {},
    /* 小程序特有相关 */
    "mp-weixin" : {
        "appid" : "wx4e7c0238b00c06d8",
        "setting" : {
            "urlCheck" : false
        },
        "usingComponents" : true
    },
    "mp-alipay" : {
        "usingComponents" : true
    },
    "mp-baidu" : {
        "usingComponents" : true
    },
    "mp-toutiao" : {
        "usingComponents" : true
    },
    "uniStatistics" : {
        "enable" : false
    },
    "vueVersion" : "3"
}


举报· 103 次点击
登录 注册 站外分享
快来抢沙发
0 条回复  
返回顶部