android - 将数据从 Android 发送到 Simblee BLE 不返回任何内容

标签 android arduino bluetooth-lowenergy simblee

下面是我的 Simblee 的草图:

#include <SimbleeBLE.h>

void setup() {
  Serial.begin(9600);
  Serial.println("Waiting for connection...");
  SimbleeBLE.deviceName = "Simblee";
  SimbleeBLE.advertisementData = "data";
//  SimbleeBLE.customUUID = "2220";
  SimbleeBLE.advertisementInterval = MILLISECONDS(300);
  SimbleeBLE.txPowerLevel = -20;  // (-20dbM to +4 dBm)
  SimbleeBLE.begin();
}

void loop() {

}

void SimbleeBLE_onConnect()
{
  Serial.println("Simblee Connected");
}

void SimbleeBLE_onDisconnect()
{
  Serial.println("Simblee Disconnected");
}

void SimbleeBLE_onReceive(byte *data, int len)
{
  Serial.println("Data received");
  SimbleeBLE.send(1);
  printf("%s\n", data);
}

void serialEvent() 
{
   Serial.println("Serial event");
}

我可以很容易地连接它并从中读取数据,但在我的应用程序中无法对其进行位写入。 SimbleeBLE_onReceive 永远不会被调用。

即使使用 nRF Connect 和 BLE 终端等第三方 BLE 应用程序,它实际上也不会被调用。

所以我怀疑问题出在我的 arduino Sketch 上,与 android 代码无关。

Android 代码在尝试写入时返回 GATT_ERROR 133。

此代码中是否缺少任何内容?奇怪的是,我在网上找不到任何我们只是将数据发送到 Simblee(不使用 SimlbeeMobile)的示例

谢谢,

最佳答案

尝试将您的 onReceive 签名更改为:

void SimbleeBLE_onReceive(char *data, int len)

关于android - 将数据从 Android 发送到 Simblee BLE 不返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47472738/

相关文章:

c - 将字符串拆分为字符串数组

iphone - 一台iPhone既是外围又是中心,可以接连连接多部外围iPhone吗?

Android 应用程序与我的设备不兼容

python - Arduino Yun Python 脚本

c++ - 我应该为初学者学习 "c or c++ "之间的哪一个来使用 Arduino UNO?

rust - 通过 Rumble 从 Bluetooth 5 LE DevBoard 读取串行数据流

android - 找出ble android中的连接间隔

android - 插件不支持该项目的 cordova-android 版本。 cordova-android : 4. 1.1,失败的版本要求 : >=5. 0.0-dev

Android Dev - R.layout.main,无法解析变量 'R'

java - fragment Activity 不膨胀