Reputation: 837
I need to connect my phone to Raspberry via Bluetooth, get list of available wifi, choose one on the phone, send it's it to Raspberry and connect to selected network.
I've chosen 'react-native-ble-manager' for react-native and bleno for raspberry.
After connection to Raspberry with my phone I'm trying to BleManager.read but readData that responds is empty String
Raspberry for Characteristics:
onReadRequest(offset, callback) => {
callback(Characteristic.RESULT_SUCCESS, new Buffer('Hello'));
});
},
React Native:
BleManager.read(peripheralInfo.id, '12AB', '34CD')
.then((readData) => {
// Success code
console.log('Read:', readData);
})
Any ideas what I'm doing wrong, and what should I change to send my message from mobile-app to the raspberry
Upvotes: 1
Views: 896
Reputation: 2671
You can not send more than 20 character at a time in BLE. So if you has large string, than data must be sent in 20 bytes chunk. This chunking is already implemented in react-native-ble-manager. So if you have string of more than than 20 character, then you will receive multiple onWriteRequest callback in periferal. You must handle that callback properly.
Upvotes: 2