接收由本机应用程序发送的数据

问题描述

一个具有反应本机的应用程序和带有ble模块mlt-bt05的arduino nano。我尝试使用react-native-ble-plx库从应用程序向arduino发送信息,但是串行监视器什么也不显示

这是我的本机代码

const msg = base64.encode(message);

let messageResponse = await connectedDevice.writeCharacteristicWithResponseForService(
  serviceUUID,uuid,msg,);

和arduino代码

#include <SoftwareSerial.h>

SoftwareSerial ble_device(3,4);

String str_ii = "";
int ii_0 = 0;

void setup() {  
  Serial.begin(115200);

  pinMode(LED_BUILTIN,OUTPUT);

  ble_device.begin(9600);

  delay(100);
}

void loop() {
  while (ble_device.available()){
    char in_char = ble_device.read();

    if (int(in_char)!=-1 and int(in_char)!=42 and in_char != '\n'){
      str_ii+=in_char;
    }

    if (in_char=='\n'){
      delay(20);
      String msg = "Msg: ";
      msg+=str_ii;
      ble_device.print(msg);

      Serial.println(str_ii);

      if (str_ii == "on") {
        digitalWrite(LED_BUILTIN,HIGH);
      } else if (str_ii == "off") {
        digitalWrite(LED_BUILTIN,LOW);
      }
      str_ii = "";
    }
  }
}

我尝试使用BLE终端应用程序通过IOS发送带有此arduino代码的数据,并且在端口监视器中我看到消息,但我的本地应用程序没有显示消息。

存在来自writeCharacteristicWithResponseForService的响应的console.log

id: 10758153120
uuid: "0000ffe1-0000-1000-8000-00805f9b34fb"
isNotifiable: true
isnotifying: false
isReadable: true
isWritableWithResponse: true
serviceID: 10773274432
value: null
isIndicatable: false
serviceUUID: "0000ffe0-0000-1000-8000-00805f9b34fb"
deviceid: "975EDC28-F6FC-562E-B837-445F2DB6865C"
isWritableWithoutResponse: true

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...