I cannot achieve proper communication with write or notify characteristic using relay (Central & Peripheral) - nrf52832

I am trying to develop a project, where I want two devices to communicate as following: one nrf52832 (let's say A) is a peripheral and has sensors-creates data and another one nrf52832 (let's say B) is a relay, it works as a central and as a peripheral. 

I have been following the example examples/ble_central_and_peripheral/experimental/ble_app_hrs_rscs_relay for the device B and examples/ble_peripheral/ble_app_hrs for device A.

I would like use a phone with nRF Connect, to write a value in a Write Characteristic and send it to device B, which then it will send it to device A. Also, from nRF Connect I want to be able to enable notifications of a Notify Characteristic, which will enable notifications first on the relay- device B and then on device A, which will send data to device B and then to the phone.

But, when I try to implement the 1st example about the Write Characteristic, I manage to write a value from the phone to the device B (relay), which then attempts to write it to device A, but then I get fatal error. The error traces back to function nrf_ble_gq_item_add() with error code 7. 
Also, i couldn't achieve the notify characteristic.

It has been confusing, since in the example of hrs/rscs, the file ble_hrs.c, seems to be commonly used both by the deivce-peripheral and device-relay when it operates as a peripheral.
But in my case, I don't want it to be exactly the same, and I haven't used a common file.

So, I would like some help if it's possible, mostly on the basic but necessary functions that I will need to achieve this and maybe some explanation of the whole flow of the program and the interaction of the functions/connection/and how the relay changes its operation between the two roles of central and peripheral.

Thanks in advance.

Related