0

我正在尝试使用 React-Native-BLE-PLX 创建一个 react-native 应用程序。对于蓝牙,我们有一个 Arduino 通过 HM10 芯片发送信息。至于 Arduino 通过 BT 发送信息,我已使用 BLE 扫描仪应用程序验证我正在将信息正确发送到服务:FFE0 / 特征:FFE1

不幸的是,当获得这项服务/特性时,我的价值完全不同并且是静态的,无论我发送什么,我都会在价值上得到相同的结果。

function* readAllCharacteristics(device: Device): Generator<*, boolean, *> {
  try {
    const services: Array<Service> = yield call([device, device.services]);
    for (const service of services) {
      yield put(log('Found service: ' + service.uuid));
      const characteristics: Array<Characteristic> = yield call([
        service,
        service.characteristics,
      ]);
      for (const characteristic of characteristics) {
        yield put(log('Found characteristic: ' + characteristic.uuid));
                if (characteristic.isReadable) {
          yield put(log('Reading value...'));
          var c = yield call([characteristic, characteristic.read]);
          console.log(c.value) //c.value = /EXDJJSw
          yield put(log('Got base64 value: ' + c.value));

          if (characteristic.isWritableWithoutResponse) {
            console.log(c.value)
            yield call(
              [characteristic, characteristic.writeWithoutResponse],
              c.value,
            );
            console.log(c.value) //c.value = /EXDJJSw
            yield put(log('Successfully written value back'));
          }
        }

在上面的代码中,我的 c.value 是我假设应该是我的特征值(我发送的)但我失败了。

您将在下面看到 BLE 扫描仪的假定结果。

我已验证服务/特性是正确的。

4

0 回答 0