Hello,
Situation:
I am trying to write a characteristic to an iOS device acting as a peripheral from a nRF51822 board. The board has 2 leds (green and red) and a button.
The iOS device is running an app exposing a service (let's say it's ID is XXXX) and it has one characteristic (YYYY).
The nRF board does the following steps when I push the button:
- Scan for any peripheral exposing the service XXXX.
- Once if finds it (BLE_GAP_EVT_ADV_REPORT) I check that the char UUID is being advertised.
- Stop scan and connect (using sd_ble_gap_scan_stop and sd_ble_gap_connect).
- Once I get the BLE_GAP_EVT_CONNECTED I start a discovery using ble_db_discovery_start.
- When I receive the BLE_DB_DISCOVERY_COMPLETE and after checking the UUID, I use a for to find the char (YYYY).
- Finally if I find the char I write 20 bytes to it (sd_ble_gattc_write and BLE_GATT_OP_WRITE_REQ).
- Once I receive the BLE_GATTC_EVT_WRITE_RSP event, I turn the green led on.
On every step of the process, if any function called returns an error or if I get an event like BLE_GAP_EVT_TIMEOUT or something that indicates something is wrong, I turn the red led on.
The problem:
When I run the app on the iOS device and I press the button on the board, the green led turns on. This shows that the char has been written successfully but the callback peripheralManager:didReceiveWriteRequests: is never called on the iOS device.
On one hand, it looks like it has been written from the board side but on the other I never receive the information on the iOS device.
What I tried:
- I changed the characteristic and service UUIDs on the iOS device to check that the board is finding the correct char, I get a red light what means that it is right with the correct values.
- I turned the iOS bluetooth off, I get a red light.
- I tried using another iOS device to write the same characteristic (YYYY) and I can write it correctly (the callback gets called).
- I tried using BLE_GATT_OP_WRITE_CMD instead of BLE_GATT_OP_WRITE_REQ and the same thing happens (I also set CBCharacteristicPropertyWriteWithoutResponse and CBCharacteristicPropertyWrite values on the iOS device to be sure).
I am kinda stuck here, I would try to use a sniffer or something to check the traffic, but I think that the problem is something I am missing here.
Any clues??
Thanks for reading!