vovagorodok / ArduinoBleOTA

Upload firmware over Bluetooth
MIT License
24 stars 8 forks source link

send begin, write is not permitted error #24

Closed sdetweil closed 1 year ago

sdetweil commented 1 year ago

I am porting your sender code to my app.. javascript(ionic/vue)

but when I try to send the begin sequence 0x10 plus data length

I get an error

⚡️  [log] - connecting for F2195DF1-3329-F489-6E77-E917B966BD9B
To Native Cordova ->  BluetoothLePlugin ⚡️  [log] - post connect device info ={"name":"b0:a7:32:81:93:e6","address":"F2195DF1-3329-F489-6E77-E917B966BD9B","status":"connected"}
discover BluetoothLePlugin1117210597 ["options": [{
    address = "F2195DF1-3329-F489-6E77-E917B966BD9B";
    clearCache = 1;
}]]
⚡️  [log] - discover results={"status":"discovered","services":[{"characteristics":[{"descriptors":[],"properties":{"write":true},"uuid":"9A61"},{"descriptors":[],"properties":{"write":true},"uuid":"9A62"},{"descriptors":[],"properties":{"write":true,"read":true},"uuid":"9AFF"},{"descriptors":[{"uuid":"2902"}],"properties":{"notify":true,"read":true},"uuid":"2A05"},{"descriptors":[],"properties":{"read":true},"uuid":"9A63"},{"descriptors":[],"properties":{"write":true},"uuid":"9A64"}],"uuid":"00000001-27B9-42F0-82AA-2E951747BBF9"},{"characteristics":[{"descriptors":[],"properties":{"write":true},"uuid":"9A61"},{"descriptors":[],"properties":{"write":true},"uuid":"9A62"},{"descriptors":[],"properties":{"write":true,"read":true},"uuid":"9AFF"},{"descriptors":[{"uuid":"2902"}],"properties":{"notify":true,"read":true},"uuid":"2A05"},{"descriptors":[],"properties":{"read":true},"uuid":"9A63"},{"descriptors":[],"properties":{"write":true},"uuid":"9A64"}],"uuid":"00000011-27B9-42F0-82AA-2E951747BBF9"},

// the ota characteristics... 

{"characteristics":[

{"descriptors":[],"properties":{"writeWithoutResponse":true},"uuid":"15C1564C-36C5-11ED-ADC1-A3D6CF5CC2A4"},

the device RX characteristic...

{"descriptors":[{"uuid":"2902"}],"properties":{"notify":true,"read":true},"uuid":"15C156E2-36C5-11ED-ADC2-7396D4FD413A"},{"descriptors":[],"properties":{"read":true},"uuid":"15C1576E-36C5-11ED-ADC3-8799895DE51E"},{"descriptors":[],"properties":{"read":true},"uuid":"15C15886-36C5-11ED-ADC5-1BC0D0A6069D"},{"descriptors":[],"properties":{"read":true},"uuid":"15C157FA-36C5-11ED-ADC4-579C60267B47"},{"descriptors":[],"properties":{"read":true},"uuid":"15C1591C-36C5-11ED-ADC6-DBE9603DBF19"}],"uuid":"15C155CA-36C5-11ED-ADC0-9741D6A72F04"}],"name":"b0:a7:32:81:93:e6","address":"F2195DF1-3329-F489-6E77-E917B966BD9B"}
⚡️  [log] - starting OTA Service

writing my characteristic to enable the OTA service (sets the enabled value) 

To Native Cordova ->  BluetoothLePlugin write BluetoothLePlugin1117210598 ["options": [{
    address = "F2195DF1-3329-F489-6E77-E917B966BD9B";
    characteristic = 9A64;
    service = "00000001-27B9-42F0-82AA-2E951747BBF9";
    value = "MQ==";
}]]
⚡️  [log] - write rc={"status":"written","characteristic":"9A64","name":"b0:a7:32:81:93:e6","service":"00000001-27B9-42F0-82AA-2E951747BBF9","address":"F2195DF1-3329-F489-6E77-E917B966BD9B"}
To Native Cordova ->  BluetoothLePlugin close BluetoothLePlugin1117210599 ⚡️  [log] - start ota after write
["options": [{
    address = "F2195DF1-3329-F489-6E77-E917B966BD9B";
}]]
To Native Cordova ->  BluetoothLePlugin connect BluetoothLePlugin1117210600 ⚡️  [log] - close rc={"name":"b0:a7:32:81:93:e6","address":"F2195DF1-3329-F489-6E77-E917B966BD9B","status":"closed"}
["options": [{
    address = "F2195DF1-3329-F489-6E77-E917B966BD9B";
}]]

device forces disconnect

⚡️  [log] - post connect device info ={"name":"b0:a7:32:81:93:e6","address":"F2195DF1-3329-F489-6E77-E917B966BD9B","status":"connected"}
To Native Cordova ->  BluetoothLePlugin services BluetoothLePlugin1117210601 ["options": [{
    address = "F2195DF1-3329-F489-6E77-E917B966BD9B";
    services =     (
        "15c155ca-36c5-11ed-adc0-9741d6a72f04"
    );
}]]

⚡️  [log] - startOTA after reconnect, services={"status":"services","services":["00000001-27B9-42F0-82AA-2E951747BBF9","00000011-27B9-42F0-82AA-2E951747BBF9","15C155CA-36C5-11ED-ADC0-9741D6A72F04"],"name":"b0:a7:32:81:93:e6","address":"F2195DF1-3329-F489-6E77-E917B966BD9B"}

// read the services.. OTA is there

⚡️  [log] -  calling discover after OTA started

⚡️  [log] - subscribing  to the TX characteristic
⚡️  [log] - subscribe rc={}

// now send the begin sequence

⚡️  [log] - starting transfer of 658448 bytes  // firmware size
⚡️  [log] -  build begin data 
------edited, had data in big endian, now in little endian
------if I send this data to the device with NnrfConnect I get back an ok response, with the two buffer sizes

⚡️  [log] - begin data to be written=10100c0a00

To Native Cordova ->  BluetoothLePlugin write BluetoothLePlugin761073956 
⚡️  characteristic = "15c1564c-36c5-11ed-adc1-a3d6cf5cc2a4";
    service = "15c155ca-36c5-11ed-adc0-9741d6a72f04";
    value = "EBAMCgA=";
}]]
⚡️  [log] - len =5
⚡️  [log] - send data error ={"error":"write","message":"Error Domain=CBATTErrorDomain Code=3 \"Writing is not permitted.\" UserInfo={NSLocalizedDescription=Writing is not permitted.}","characteristic":"15C1564C-36C5-11ED-ADC1-A3D6CF5CC2A4","name":"b0:a7:32:81:93:e6","service":"15C155CA-36C5-11ED-ADC0-9741D6A72F04","address":"F2195DF1-3329-F489-6E77-E917B966BD9B"}
⚡️  [log] - post connect device info ={"name":"b0:a7:32:81:93:e6","address":"F2195DF1-3329-F489-6E77-E917B966BD9B","status":"disconnected"}
To Native Cordova ->  BluetoothLePlugin services BluetoothLePlugin761073957 ["options": [{
    address = "F2195DF1-3329-F489-6E77-E917B966BD9B";
    services =     (
        "15c155ca-36c5-11ed-adc0-9741d6a72f04"
    );
}]]

I assume u don't see this in your flutter app.. and the python uploader works when in this state..

I write json data and text numbers without problem.. just no binary data

sdetweil commented 1 year ago

I am able to read from the device name and sw name characteristics

sdetweil commented 1 year ago

never mind, dumb.. I have to tell the library 'noResponse' on the write.. it doesn't look at the characteristic settings...