React Native BLE Manager write function is not working

69 views Asked by At

i can connect and read data but when i want to send data, it is not working. i tried on nrfconnect app and i can send data and open light well. here is my code.

 const openLight = async (peripheral: Peripheral) => {
    let serviceUUID = "";
    let characteristicUUID = "";
  
    try {
      const peripheralInfo = await BleManager.retrieveServices(peripheral.id);
      if (!peripheralInfo.characteristics || peripheralInfo.characteristics.length < 7) {
        throw new Error("Required characteristics not found");
      }
      characteristicUUID = peripheralInfo.characteristics[6].characteristic;
      serviceUUID = peripheralInfo.characteristics[6].service;
      await BleManager.startNotification(peripheral.id, serviceUUID, characteristicUUID);
      await BleManager.writeWithoutResponse(peripheral.id, serviceUUID, characteristicUUID, [49]);
      Alert.alert("Ok");
    } catch (error) {
      Alert.alert("Error!", JSON.stringify(error));
    }
  };

i tried documentation code, i tried debug my nordic board and value is not coming nordic board, if i tried nrfconnect app, i can watch value but if i use my code instead of nrf connect, i can't watch value because there are no value...characteristicUUID and serviceUUID are true. it alert "ok"

0

There are 0 answers