react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

Sending Data

Open marwakhalil opened this issue 9 years ago • 11 comments

Can i send data through this libraries, I am connecting to a DA14680 chip through react native ble plx app and i want to send a json file is that possible ? Thanks

marwakhalil avatar May 18 '17 13:05 marwakhalil

I have never worked with DA14680 but it looks like it supports BLE, so it's doable. Just remember that characteristic reads and writes are limited to negotiated MTU which is lower then 512B. I would suggest to use JSON binary format to compress data as much as possible (like MessagePack) to send as little chunks as possible via characteristics.

Cierpliwy avatar May 18 '17 14:05 Cierpliwy

@Cierpliwy Okay this is great, sufficient for my needs
actually i would be glad if you give me the name of the method to send data, and just for the information, can i connect and send data to a smartphone advertised as an ibeacon??? Thanks

marwakhalil avatar May 18 '17 14:05 marwakhalil

I recommend to read intro page of documentation and check functions in it: https://polidea.github.io/react-native-ble-plx/

Cierpliwy avatar May 18 '17 15:05 Cierpliwy

@marwakhalil did you get it to work?

briancohn avatar May 25 '17 00:05 briancohn

@briancohn , yes i used writeCharacteristicWithResponseForDevice() and it worked

marwakhalil avatar May 29 '17 07:05 marwakhalil

@marwakhalil, can you show example how you did it?

0lide avatar Jun 06 '17 16:06 0lide

@marwakhalil I'd really appreciate that too, thanks so much

briancohn avatar Jun 06 '17 19:06 briancohn

`scan() { this.manager.startDeviceScan(null, null, (error, device) => { if (error) { console.log("something went wrong"); return; } console.log("device id est : " + device.id + "device name : " + device.name + "device is connectable : " + device.isConnectable + "rssi : " + device.rssi); if (device.id === ‘XX:XX:XX:XX:XX:XX’) { this.manager.stopDeviceScan(); device.connect() .then((device) => { return device.discoverAllServicesAndCharacteristics(); console.log('connected'); })

}

}) }

send() { this.manager.writeCharacteristicWithResponseForDevice(deviceId, serviceId, characteristicId, base64Value) .catch((error) => { console.log('error in writing data'); console.log(error);

})

}

`

i made a scan for all devices and i fixed a mac id for testing

marwakhalil avatar Jun 07 '17 14:06 marwakhalil

Hi,

I have same issue, @marwakhalil or anybody else could you post a working code example ? I can't figure out how you find serviceId and characteristicId ...

Thx

therveux avatar May 02 '18 14:05 therveux

@Hurobaki I know it's 2023, but have you found a solution to your question? I have the same trouble now.

shonie2xx avatar Jan 08 '23 20:01 shonie2xx

So how to get the serviceId and characteristicId? If someone knows about this, please let me know. Thank U so much!

arlovip avatar May 12 '23 09:05 arlovip