codecamp

setBluetoothDevice

设置蓝牙连接对象。如果不需要返回结果,可以不用设置回调方法。

setBluetoothDevice({par},callback(ret,err));

par

name:

  • 类型:字符串类型;
  • 描述:蓝牙名称

callback(ret,err)

ret:

  • 类型:JSON对象
  • 描述:返回相关信息
  • 内部字段:

    {
        states://BOOL值,返回执行过程中的成功或者失败
        message://String类型,返回执行过程中的相关信息
        data://状态码,当为获取蓝牙列表的时候返回类型是String,其余返回均为数值类型。
    }

err:

  • 类型:布尔值
  • 内部字段:

{true;//布尔型;true||false,该参数表示原生回调成功}

示例代码

var printUtils=api.require('wwprint');
var str={name:'P50---XXX'};
printUtils.setBluetoothDevice(str,function(ret,err){
    alert(ret.message);
})

补充说明

设置蓝牙连接对象的时,如果已经连接上了,返回连接失败。所以需要保证设备处于未连接状态。

可用性

Android系统,iOS系统

可提供1.0.0及更高的版本

print
getBluetoothDeviceList
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

端API

设备访问

ipAddress

wifiSSID

smartConfigCheyw

无标题文章

前端框架

云API

开发工具

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }