randdusing / cordova-plugin-bluetoothle

Bluetooth Low Energy Phonegap Plugin
803 stars 354 forks source link

Subscribe question #28

Closed webquali closed 10 years ago

webquali commented 10 years ago

I have this way: StartScan -> Connect -> StopScan -> Write -> Read But read last bytes. I want read all data and start Subscribe but all time after subscribe have the same data. My device have feature when I make Subscribe device restarted. You can explain how right? How I can read all data after write command? I am desperate Thanks!

randdusing commented 10 years ago

Hi webquali,

Not sure if I completed understand your request. Is subscribe not working at all? Or is returning the same data every time?

webquali commented 10 years ago

Yes I think not working at all.

I send command "AT DP\r" it will return "ISO15765-4(CAN 29/250)" But when I use Write -> Subscribe have returned data: A TZ

ELM327 v2.0

randdusing commented 10 years ago

What type of device, service UUID and characteristic UUID? I was unable to change the device name of my heart rate monitor using the characteristic below. https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.device_name.xml

webquali commented 10 years ago

https://github.com/pronix/citozin-hardware/blob/master/firmware/v1.1.0/gatt.xml#L15

randdusing commented 10 years ago

Can you post a more specific workflow of what your code is doing?

For example, Write characteristic 1234, Wait for write response, Read characteristic 2345, Wait for read response, Subscribe characteristic 3456, Wait for subscribe notifications, etc

webquali commented 10 years ago

My device used Bluegiga module https://www.bluegiga.com/en-US/products/bluetooth-4.0-modules/ble112-bluetooth--smart-module/

2014-04-08 00:46:32.325 Citozin[2926:60b] Multi-tasking -> Device: YES, App: YES 2014-04-08 00:46:33.021 Citozin[2926:60b] Resetting plugins due to page load. 2014-04-08 00:46:34.188 Citozin[2926:60b] Finished load of: file:///var/mobile/Applications/427CA109-34D7-4058-8AE4-222EF75B984C/Citozin.app/www/index.html 2014-04-08 00:46:40.493 Citozin[2926:60b] getServices params 2014-04-08 00:46:40.494 Citozin[2926:60b] {} 2014-04-08 00:46:40.498 Citozin[2926:60b] {"status":"discoveredServices","name":"Citozin-OBDII v1.1","address":"91173752-3C45-2561-69F8-49F55130D346","serviceUuids":["8f544040-af98-11e3-8b63-69746f7a696e","adc97e00-af98-11e3-8763-69746f7a696e"]} 2014-04-08 00:46:40.499 Citozin[2926:60b] {"serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:40.507 Citozin[2926:60b] {"status":"discoveredCharacteristics","name":"Citozin-OBDII v1.1","characteristicUuids":["b55b5bc0-af98-11e3-9163-69746f7a696e"],"serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e","address":"91173752-3C45-2561-69F8-49F55130D346"} 2014-04-08 00:46:40.508 Citozin[2926:60b] b55b5bc0-af98-11e3-9163-69746f7a696e 2014-04-08 00:46:40.508 Citozin[2926:60b] Unit8 arr 2014-04-08 00:46:40.509 Citozin[2926:60b] {"0":65,"1":84,"2":32,"3":68,"4":80,"5":13,"length":6,"byteOffset":0,"buffer":{"byteLength":6},"byteLength":6} 2014-04-08 00:46:40.509 Citozin[2926:60b] writeData Params 2014-04-08 00:46:40.509 Citozin[2926:60b] {"value":"QVQgRFAN","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e","characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e"} 2014-04-08 00:46:40.570 Citozin[2926:60b] {"characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e","status":"written","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:40.572 Citozin[2926:60b] getServices params 2014-04-08 00:46:40.573 Citozin[2926:60b] {} 2014-04-08 00:46:40.575 Citozin[2926:60b] writeSuccessCallback 2014-04-08 00:46:40.576 Citozin[2926:60b] {"characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e","status":"written","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:40.582 Citozin[2926:60b] {"status":"discoveredServices","name":"Citozin-OBDII v1.1","address":"91173752-3C45-2561-69F8-49F55130D346","serviceUuids":["8f544040-af98-11e3-8b63-69746f7a696e","adc97e00-af98-11e3-8763-69746f7a696e"]} 2014-04-08 00:46:40.627 Citozin[2926:60b] Subscription started 2014-04-08 00:46:41.560 Citozin[2926:60b] Read bytes:

2014-04-08 00:46:41.564 Citozin[2926:60b] Read bytes:

ELM327 v2.0

2014-04-08 00:46:41.566 Citozin[2926:60b] Read bytes: > 2014-04-08 00:46:45.658 Citozin[2926:60b] Unsubscribed device 2014-04-08 00:46:48.068 Citozin[2926:60b] getServices params 2014-04-08 00:46:48.069 Citozin[2926:60b] {} 2014-04-08 00:46:48.076 Citozin[2926:60b] {"status":"discoveredServices","name":"Citozin-OBDII v1.1","address":"91173752-3C45-2561-69F8-49F55130D346","serviceUuids":["8f544040-af98-11e3-8b63-69746f7a696e","adc97e00-af98-11e3-8763-69746f7a696e"]} 2014-04-08 00:46:48.076 Citozin[2926:60b] {"serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:48.104 Citozin[2926:60b] {"status":"discoveredCharacteristics","name":"Citozin-OBDII v1.1","characteristicUuids":["b55b5bc0-af98-11e3-9163-69746f7a696e"],"serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e","address":"91173752-3C45-2561-69F8-49F55130D346"} 2014-04-08 00:46:48.105 Citozin[2926:60b] b55b5bc0-af98-11e3-9163-69746f7a696e 2014-04-08 00:46:48.106 Citozin[2926:60b] Unit8 arr 2014-04-08 00:46:48.106 Citozin[2926:60b] {"0":65,"1":84,"2":32,"3":68,"4":80,"5":13,"length":6,"byteOffset":0,"buffer":{"byteLength":6},"byteLength":6} 2014-04-08 00:46:48.107 Citozin[2926:60b] writeData Params 2014-04-08 00:46:48.107 Citozin[2926:60b] {"value":"QVQgRFAN","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e","characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e"} 2014-04-08 00:46:48.159 Citozin[2926:60b] {"characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e","status":"written","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:48.160 Citozin[2926:60b] getServices params 2014-04-08 00:46:48.161 Citozin[2926:60b] {} 2014-04-08 00:46:48.162 Citozin[2926:60b] writeSuccessCallback 2014-04-08 00:46:48.163 Citozin[2926:60b] {"characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e","status":"written","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:48.205 Citozin[2926:60b] {"status":"discoveredServices","name":"Citozin-OBDII v1.1","address":"91173752-3C45-2561-69F8-49F55130D346","serviceUuids":["8f544040-af98-11e3-8b63-69746f7a696e","adc97e00-af98-11e3-8763-69746f7a696e"]} 2014-04-08 00:46:48.247 Citozin[2926:60b] Subscription started 2014-04-08 00:46:48.249 Citozin[2926:60b] Read bytes: A 2014-04-08 00:46:48.250 Citozin[2926:60b] Read bytes: TZ

2014-04-08 00:46:49.029 Citozin[2926:60b] Read bytes:

2014-04-08 00:46:49.033 Citozin[2926:60b] Read bytes:

ELM327 v2.0

2014-04-08 00:46:49.035 Citozin[2926:60b] Read bytes: > 2014-04-08 00:46:53.275 Citozin[2926:60b] Unsubscribed device 2014-04-08 00:46:57.883 Citozin[2926:60b] getServices params 2014-04-08 00:46:57.884 Citozin[2926:60b] {} 2014-04-08 00:46:57.888 Citozin[2926:60b] {"status":"discoveredServices","name":"Citozin-OBDII v1.1","address":"91173752-3C45-2561-69F8-49F55130D346","serviceUuids":["8f544040-af98-11e3-8b63-69746f7a696e","adc97e00-af98-11e3-8763-69746f7a696e"]} 2014-04-08 00:46:57.889 Citozin[2926:60b] {"serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:57.893 Citozin[2926:60b] {"status":"discoveredCharacteristics","name":"Citozin-OBDII v1.1","characteristicUuids":["b55b5bc0-af98-11e3-9163-69746f7a696e"],"serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e","address":"91173752-3C45-2561-69F8-49F55130D346"} 2014-04-08 00:46:57.894 Citozin[2926:60b] b55b5bc0-af98-11e3-9163-69746f7a696e 2014-04-08 00:46:57.895 Citozin[2926:60b] Unit8 arr 2014-04-08 00:46:57.895 Citozin[2926:60b] {"0":65,"1":84,"2":32,"3":68,"4":80,"5":13,"length":6,"byteOffset":0,"buffer":{"byteLength":6},"byteLength":6} 2014-04-08 00:46:57.896 Citozin[2926:60b] writeData Params 2014-04-08 00:46:57.896 Citozin[2926:60b] {"value":"QVQgRFAN","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e","characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e"} 2014-04-08 00:46:57.938 Citozin[2926:60b] {"characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e","status":"written","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:57.939 Citozin[2926:60b] getServices params 2014-04-08 00:46:57.939 Citozin[2926:60b] {} 2014-04-08 00:46:57.940 Citozin[2926:60b] writeSuccessCallback 2014-04-08 00:46:57.940 Citozin[2926:60b] {"characteristicUuid":"b55b5bc0-af98-11e3-9163-69746f7a696e","status":"written","serviceUuid":"adc97e00-af98-11e3-8763-69746f7a696e"} 2014-04-08 00:46:57.945 Citozin[2926:60b] {"status":"discoveredServices","name":"Citozin-OBDII v1.1","address":"91173752-3C45-2561-69F8-49F55130D346","serviceUuids":["8f544040-af98-11e3-8b63-69746f7a696e","adc97e00-af98-11e3-8763-69746f7a696e"]} 2014-04-08 00:46:57.998 Citozin[2926:60b] Subscription started 2014-04-08 00:46:58.002 Citozin[2926:60b] Read bytes: A 2014-04-08 00:46:58.004 Citozin[2926:60b] Read bytes: TZ

2014-04-08 00:46:58.780 Citozin[2926:60b] Read bytes:

2014-04-08 00:46:58.783 Citozin[2926:60b] Read bytes:

ELM327 v2.0

2014-04-08 00:46:58.786 Citozin[2926:60b] Read bytes: > 2014-04-08 00:47:03.009 Citozin[2926:60b] Unsubscribed device

randdusing commented 10 years ago

You may want to hardcode the write value temporarily to ensure that there isn't any issues with the string encoding. Also, do you know what string encoding type the remote device is expecting? The code above may be using a different encoding.

webquali commented 10 years ago

No all good with write value and the encoding too. Fo example: When I do this Value to write = "AT DP\r" Steps: Write -> Read And non use Subscribe. I have in Read data this "29/250)" It's part of "ISO15765-4(CAN 29/250)"

webquali commented 10 years ago

Write command work greate, but my problem I don't read all data

webquali commented 10 years ago

Maybe I can share my code to you? Do you have skype?

randdusing commented 10 years ago

Is there any way to confirm what the Bluetooth device is actually sending? You can send it to my {username}@gmail.com if you'd like