react-native-ble-manager: Getting error code- 128 while writing to characterstic
value = 0xB0010A0
//removing 0x from string becuase below code is not able to convert hex to base64.
const base64String = new Buffer('B0010A0', 'hex').toString('base64'); this.props.writeCharacteristic(deviceId, serviceUUID, charactericticUUID, base64String); after write complete i am getting write fail with -128.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 26 (10 by maintainers)
@marcosinigaglia Thanks for help and support. everything is working fine now. 👍
@shubham0390 i’ve seen that you are interested on iqos device, how i can contact you? do you have telegram?
Here is code snippet
` connectPeripheral = (selectedPeripheralId) => { this.props.changePeripheralState(selectedPeripheralId, PERIPHERAL_CONNECTION_STATE.CONNECTING); BleManager.connect(selectedPeripheralId) .then((peripheralInfo) => { this.onPeripheralConnected(selectedPeripheralId, peripheralInfo); }) .catch((error) => { this.props.pushError(error); }); };
onPeripheralConnected = (selectedPeripheralId, peripheralInfo) => { const servicesMap = mapServicesAndCharacteristics(peripheralInfo.services,
peripheralInfo.characteristics); this.props.updateServices(selectedPeripheralId, servicesMap); setTimeout(() => { this.startCharacteristicNotification(newProps.selectedPeripheralId, primaryService.UUID,
primaryService.BATTERY_INFO.uuid, true); }, 2000); };
startCharacteristicNotification=(peripheralId, serviceId, characteristicUUID, transactionId) => { BleManager.startNotification(peripheralId, serviceId, characteristicUUID) .then(() => { this.props.updateCharacteristic(peripheralId, serviceId, characteristicUUID, { isNotifying: true }); this.props.completeTransaction(transactionId); setTimeout(() => { const base64String = new Buffer(‘00C00120F5’, ‘hex’).toString(‘base64’); this.props.writeCharacteristic(this.props.selectedPeripheralId, primaryService.UUID, primaryService.SCP_CHARACTERISTICS.uuid, base64String); }, 2000); }) .catch((error) => { this.props.pushError(error); this.props.completeTransaction(transactionId); }); };
};`