教程背景
这里的操作是用微信开发者工具开发的小程序,并不是uniapp开发兼容的小程序教程。整体上大同小异。
官方API地址
https://developers.weixin.qq.com/miniprogram/dev/framework/device/ble.html
教程开始
1、参照uniapp+vue2开发蓝牙的教程
https://blog.csdn.net/renkai721/article/details/139604785
2、关键字替换
1、不需要引入任何JS
2、把方法中的plus.bluetooth替换为wx即可,方法名称都不需要修改
3、关键方法参数修改
// 小程序写法
wx.onBLECharacteristicValueChange((e) => {
// 这里的(e) => 非常关键,不能写成function(e)否则无法读取数据
console.log(e.value);
});
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,// 非常关键,否则无法读取数据
success: function(e) {
// console.log('success');
},
fail: function(e) {
// console.log('fail');
}
})
// uniapp写法
plus.bluetooth.onBLECharacteristicValueChange(function(e) {
console.log(e.value);
});
plus.bluetooth.notifyBLECharacteristicValueChange({
deviceId: _this.deviceId,
serviceId: _this.serviceId,
characteristicId: characteristic.uuid,
success: function(e) {
// console.log('success');
},
fail: function(e) {
// console.log('fail');
}
});
结束
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
package cn.renkai721.bean.vo;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MakeUpTheWordCount {
private String make_up_the_word_count_column_999999999_1;
private String make_up_the_word_count_column_999999999_2;
private String make_up_the_word_count_column_999999999_3;
private String make_up_the_word_count_column_999999999_4;
private String make_up_the_word_count_column_999999999_5;
private String make_up_the_word_count_column_999999999_6;
private String make_up_the_word_count_column_999999999_7;
private String make_up_the_word_count_column_999999999_8;
private String make_up_the_word_count_column_999999999_9;
private String make_up_the_word_count_column_999999999_10;
private String make_up_the_word_count_column_999999999_11;
private String make_up_the_word_count_column_999999999_12;
private String make_up_the_word_count_column_999999999_13;
private String make_up_the_word_count_column_999999999_14;
private String make_up_the_word_count_column_999999999_15;
private String make_up_the_word_count_column_999999999_16;
private String make_up_the_word_count_column_999999999_17;
private String make_up_the_word_count_column_999999999_18;
private String make_up_the_word_count_column_999999999_19;
private String make_up_the_word_count_column_999999999_20;
public String getMake_up_the_word_count_column_999999999_1() {
return make_up_the_word_count_column_999999999_1;
}
public void setMake_up_the_word_count_column_999999999_1(String make_up_the_word_count_column_999999999_1) {
this.make_up_the_word_count_column_999999999_1 = make_up_the_word_count_column_999999999_1;
}
public String getMake_up_the_word_count_column_999999999_2() {
return make_up_the_word_count_column_999999999_2;
}
public void setMake_up_the_word_count_column_999999999_2(String make_up_the_word_count_column_999999999_2) {
this.make_up_the_word_count_column_999999999_2 = make_up_the_word_count_column_999999999_2;
}
public String getMake_up_the_word_count_column_999999999_3() {
return make_up_the_word_count_column_999999999_3;
}
public void setMake_up_the_word_count_column_999999999_3(String make_up_the_word_count_column_999999999_3) {
this.make_up_the_word_count_column_999999999_3 = make_up_the_word_count_column_999999999_3;
}
public String getMake_up_the_word_count_column_999999999_4() {
return make_up_the_word_count_column_999999999_4;
}
public void setMake_up_the_word_count_column_999999999_4(String make_up_the_word_count_column_999999999_4) {
this.make_up_the_word_count_column_999999999_4 = make_up_the_word_count_column_999999999_4;
}
public String getMake_up_the_word_count_column_999999999_5() {
return make_up_the_word_count_column_999999999_5;
}
public void setMake_up_the_word_count_column_999999999_5(String make_up_the_word_count_column_999999999_5) {
this.make_up_the_word_count_column_999999999_5 = make_up_the_word_count_column_999999999_5;
}
public String getMake_up_the_word_count_column_999999999_6() {
return make_up_the_word_count_column_999999999_6;
}
public void setMake_up_the_word_count_column_999999999_6(String make_up_the_word_count_column_999999999_6) {
this.make_up_the_word_count_column_999999999_6 = make_up_the_word_count_column_999999999_6;
}
public String getMake_up_the_word_count_column_999999999_7() {
return make_up_the_word_count_column_999999999_7;
}
public void setMake_up_the_word_count_column_999999999_7(String make_up_the_word_count_column_999999999_7) {
this.make_up_the_word_count_column_999999999_7 = make_up_the_word_count_column_999999999_7;
}
public String getMake_up_the_word_count_column_999999999_8() {
return make_up_the_word_count_column_999999999_8;
}
public void setMake_up_the_word_count_column_999999999_8(String make_up_the_word_count_column_999999999_8) {
this.make_up_the_word_count_column_999999999_8 = make_up_the_word_count_column_999999999_8;
}
public String getMake_up_the_word_count_column_999999999_9() {
return make_up_the_word_count_column_999999999_9;
}
public void setMake_up_the_word_count_column_999999999_9(String make_up_the_word_count_column_999999999_9) {
this.make_up_the_word_count_column_999999999_9 = make_up_the_word_count_column_999999999_9;
}
public String getMake_up_the_word_count_column_999999999_10() {
return make_up_the_word_count_column_999999999_10;
}
public void setMake_up_the_word_count_column_999999999_10(String make_up_the_word_count_column_999999999_10) {
this.make_up_the_word_count_column_999999999_10 = make_up_the_word_count_column_999999999_10;
}
public String getMake_up_the_word_count_column_999999999_11() {
return make_up_the_word_count_column_999999999_11;
}
public void setMake_up_the_word_count_column_999999999_11(String make_up_the_word_count_column_999999999_11) {
this.make_up_the_word_count_column_999999999_11 = make_up_the_word_count_column_999999999_11;
}
public String getMake_up_the_word_count_column_999999999_12() {
return make_up_the_word_count_column_999999999_12;
}
public void setMake_up_the_word_count_column_999999999_12(String make_up_the_word_count_column_999999999_12) {
this.make_up_the_word_count_column_999999999_12 = make_up_the_word_count_column_999999999_12;
}
public String getMake_up_the_word_count_column_999999999_13() {
return make_up_the_word_count_column_999999999_13;
}
public void setMake_up_the_word_count_column_999999999_13(String make_up_the_word_count_column_999999999_13) {
this.make_up_the_word_count_column_999999999_13 = make_up_the_word_count_column_999999999_13;
}
public String getMake_up_the_word_count_column_999999999_14() {
return make_up_the_word_count_column_999999999_14;
}
public void setMake_up_the_word_count_column_999999999_14(String make_up_the_word_count_column_999999999_14) {
this.make_up_the_word_count_column_999999999_14 = make_up_the_word_count_column_999999999_14;
}
public String getMake_up_the_word_count_column_999999999_15() {
return make_up_the_word_count_column_999999999_15;
}
public void setMake_up_the_word_count_column_999999999_15(String make_up_the_word_count_column_999999999_15) {
this.make_up_the_word_count_column_999999999_15 = make_up_the_word_count_column_999999999_15;
}
public String getMake_up_the_word_count_column_999999999_16() {
return make_up_the_word_count_column_999999999_16;
}
public void setMake_up_the_word_count_column_999999999_16(String make_up_the_word_count_column_999999999_16) {
this.make_up_the_word_count_column_999999999_16 = make_up_the_word_count_column_999999999_16;
}
public String getMake_up_the_word_count_column_999999999_17() {
return make_up_the_word_count_column_999999999_17;
}
public void setMake_up_the_word_count_column_999999999_17(String make_up_the_word_count_column_999999999_17) {
this.make_up_the_word_count_column_999999999_17 = make_up_the_word_count_column_999999999_17;
}
public String getMake_up_the_word_count_column_999999999_18() {
return make_up_the_word_count_column_999999999_18;
}
public void setMake_up_the_word_count_column_999999999_18(String make_up_the_word_count_column_999999999_18) {
this.make_up_the_word_count_column_999999999_18 = make_up_the_word_count_column_999999999_18;
}
public String getMake_up_the_word_count_column_999999999_19() {
return make_up_the_word_count_column_999999999_19;
}
public void setMake_up_the_word_count_column_999999999_19(String make_up_the_word_count_column_999999999_19) {
this.make_up_the_word_count_column_999999999_19 = make_up_the_word_count_column_999999999_19;
}
public String getMake_up_the_word_count_column_999999999_20() {
return make_up_the_word_count_column_999999999_20;
}
public void setMake_up_the_word_count_column_999999999_20(String make_up_the_word_count_column_999999999_20) {
this.make_up_the_word_count_column_999999999_20 = make_up_the_word_count_column_999999999_20;
}
}