i need help: i try to send one single number between 0 and 9 from my iPhone to the BLE Shield and then to the Arduino.
My Code on the Arduino is working. Tested via USB an CoolTerm's "Send Serial command" feature.
But when I send data from the BLExplr iPhone app (from the AppStore) the data will be "corrupted" until it will be received by the Arduino code.
Here is my code:
<service uuid="482AFEB3-47F7-4992-9359-D4CE424AA3E3" advertise="true">
<characteristic uuid="8D701095-B8C9-4150-BB8A-55FE65425420" id="xgatt_test">
<properties read="true" write="true" />
<value length="1" value="hex" variable_length="false"></value>
event attributes_value(connection, reason, handle, offset, value_len, value_data)
memcpy(test(0), value_data(0), 1)
if handle = xgatt_test then
test(1:1) = $31 #49 dezimal # = 1
#call attributes_write(xgatt_test, 0, 1, test(0:1)) #save data in GATT
call system_endpoint_tx(system_endpoint_uart1, 2, test(0:2)) #send data to Arduino
I just want to send 1 Byte of data to my Arduino. To explain my code: when the attributes_value event occurs, I copy the value_data to my "test" variable. Then I set a second byte ($31) to my "Test" variable. The reason for this is my Arduino code: there I want to differ between several data attributes. There first byte explains the value of my data and the second byte the type. For example "91" means power=9 and type=1
btw: if you have a better solution please tell me. but as far as I understood the Arduino Serial reads only byte by byte.
The problem is that when I am doing a Serial.read in my Arduino code I will always receive strange data. I am not able to receive the data from the bgscript. for example instead of receiving "11" I get ".J" or other strange values.
So what is going wrong here?
And what about the issue of not to use the USB cable from my PC to the Arduino as long as I am using the BLE Shield ontop of the Arduino: can that cause this issue? but on the other hand I already tried that but that doens't helped me neither...
And I there a possiblity to debug the BGScript in general?