sd_ble_gatts_hvx returns error 0x3401

Hello 

We are using sdk 17.0.2 and softdevice s140_nrf52_7.2.0_softdevice

We are using both central and peripheral mode in our application.

First we start advertisement and mobile application connects with our device.

When mobile connects with our device we start scanning and when particular device found in scanning then we will connect with that device.

We have one service fitness machine (UUID = 0x1826) and we initialise this service in both central and peripheral mode.This service supports notification.

when we connect from mobile(Central) to device(Peripheral) and if we don't start scanning  and connect to other device then we are able to send notification from our device to mobile.

But after mobile connects to device and device connects to other device then if we try to send notification then we are getting the error 0x3401 in return   sd_ble_gatts_hvx() function.

We tried to set the attribute using the  err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);  when we received connect event .But we are still getting the same error 0x3401 when we try to send notification.

So as we mentioned above if we don't start central mode in our device then we are not getting any issue in notification .

Also if  we start central mode first and connect with other device and then we mobile connects to our device then we are not getting any issue in notification.

So ,Problem occurs only when device connects to mobile (In Peripheral Mode first) and then connects to other device(in central mode). 

below are our Debug Logs

<info> app: CONFIG_JLINK_MONITOR_ENABLED

<info> app: RTC1_FREQ=32768.00, RTC1_STEP_MS=0.03

<info> app: TIMER1_STEP_MS=0.03

<info> app: SAMPLING_FREQ=100, SAMPLING_RATE_MS=10.00

<info> app: MAX_FTM_LEN=244,MAX_BLE_PACKET_BYTE_SIZE=204

<info> CSH: BT Service Init: Done



<info> CSH: UT Service Init: Done



<info> CSH: FM Service Init: Done



<info> app: Logging for over RTT started.

<info> app: 

<info> app: B0h = 0x6

<info> app: [DBG] Init Btns = 0

<info> app:   | Client Connected

<info> app: m_conn_handle=1

<info> app: Data len is set to 0xF4(244)

<info> app: Data len is set to 0xF1(241)

<info> app: In Notification Enabled

<info> app: IN SCAN START

<info> app: Going into scanning...

<info> app: CENTRAL: Connected, handle: 0.

<info> app: CENTRAL: Searching for HRS on conn_handle 0x0

<info> CSH: CSHi_HandleDiscoveryEvent

<info> app: BT_UUID_SERVICE

<info> app: BT UUID = 0x180F

<info> app: BT UUID TYPE = 1

<info> app: ntfRdHandle = 19



<info> app: ntfCccdHandle = 20



<info> CSH: BT client: connHandle 0: Discovery Completed



<info> CSH: CSHi_HandleDiscoveryEvent

<info> app: UT_UUID_SERVICE

<info> app: UT UUID = 0x1

<info> app: UT UUID TYPE = 2

<info> app: wrHandle = 13



<info> app: ntfRdHandle = 15



<info> app: ntfCccdHandle = 16



<info> CSH: UT client: connHandle 0: Discovery Completed



<info> CSH: CSHi_HandleDiscoveryEvent

<info> app: FM_UUID_SERVICE

<info> app: FM UUID = 0x1826

<info> app: FM UUID TYPE = 1

<info> app: ntfHandle = 24



<info> CSH: FM client: connHandle 0: Discovery Completed



<info> CSH: CSHi_HandleDiscoveryEvent

<info> CSH: CSHi_HandleDiscoveryEvent

<info> app: In CCCD Configure Write

<info> app: CCCD Handle in cccd Write = 24 

<info> app: Conn Handle in CCCD write = 0 

<info> app: Ret Code of cccd Write = 0

<info> app: [nus_data_handler] Received data. Writing data on UART.

<info> app:   | dATA: 0x9

<info> app:   | dATA: 0x0

<info> app:   | dATA: 0x0

<info> app:   | dATA: 0x9

<info> app: ACK Send

<info> app: [nus_data_handler] Received data. Writing data on UART.

<info> app:   | dATA: 0x6

<info> app:   | dATA: 0x35

<info> app:   | dATA: 0x5

<info> app:   | dATA: 0xC5

<info> app:   | dATA: 0x1

<info> app:   | dATA: 0x5

<info> app: [DBG] START ACTIVITY RECEIVED

<info> app:   | current_time : month = 1, day = 1, 0h:0mn:49sc:164ms

<info> app:   | received wait time p_data[2]=0x5 + p_data[3]=0xC5

<info> app:   | need to wait 1477ms

<info> app: [inspect_checksum] : START_ACTIVITY

<info> app: Data Length in Bytes =4

<info> app: Data  =6

<info> app: Data  =0

<info> app: Data  =0

<info> app: Data  =6

<info> app: Handle Value in HVX = 23

<info> app: Gatts hvx errcode = 3401

<info> app:   | ALL RIGHT

<info> app: ACK Send


can you help us to resolve this issu?


Omkar Rana

Related