bt_gatt_notify returning -ENOTCONN

I am trying to send a notification in a new device we are developing, something which I have done many times before. I am using Zephyr 1.4.1

Here is how I set up the service

//Vendor Primary Service Declaration

//force characteristic
NULL, write_force, force_value),

BT_GATT_CCC(force_ccc_cfg_changed, BT_GATT_PERM_WRITE), //2

//ROM characteristic
read_rom, write_rom, rom_value),

BT_GATT_CCC(rom_ccc_cfg_changed, BT_GATT_PERM_WRITE), //4

To send a notification for the ROM characteristic I am using this code:

uint8_t temp = 50;

int result = bt_gatt_notify(NULL, &vnd_svc.attrs[3], &temp, sizeof(temp ));
printk("notify result %d %02X\n", result, result);

For some reason I am receiving -128 or -0x80, which is -ENOTCONN if I look at errno.h

Now if I change the above line and use vnd_svc.attrs[1], there is no problem.  Everything works fine.  But I cannot figure out why.  I am connected to the device

  • Hi, 

    Have a look bt_gatt_notify (structbt_conn*conn, conststruct bt_gatt_attr*attr, constvoid*data, uint16_tlen)

    Notify attribute value change.

    Send notification of attribute value change, if connection is NULL notify all peer that have notification enabled via CCC otherwise do a direct notification only the given connection.

    The attribute object on the parameters can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC.

    • conn – Connection object.

    • attr – Characteristic or Characteristic Value attribute.

    • data – Pointer to Attribute data.

    • len – Attribute value length.


    0 in case of success or negative value in case of error.


    struct bt_gatt_attr
    #include <gatt.h>

    GATT Attribute structure.

    Public Members


    Attribute UUID


    Attribute read callback.

    The callback can also be used locally to read the contents of the attribute in which case no connection will be set.

    • conn – The connection that is requesting to read

    • attr – The attribute that’s being read

    • buf – Buffer to place the read result in

    • len – Length of data to read

    • offset – Offset to start reading from


    Number fo bytes read, or in case of an error BT_GATT_ERR() with a specific ATT error code.


  • Hi Amanda,

    Thanks for the function signatures, but I am not sure how that will help me.

    I forgot to mention there is no problem reading and writing to the characteristic in question.  Only notifications for this characteristic have an issue.

    I can keep all my code the same, but change which characteristic I use to notify and there is no issue.

  • I have the same issue using Zephyr 3.1, would be great if Nordic could provide some input!

  • Hi, 

    Please use Zephyr provided by NCS. We only support nRF Connect SDK in our integration layer and we can't really help if the customer wants to use the vanilla Zephyr. All the development was with nRF Connect SDK in mind, and we cannot guarantee it will work without code changes in a different context.

    If you still have an issue with NCS, please create a new support case and describe the problem with the NCS version. I will be out of the office for two weeks and would not reply to this case. 


  • Was there any update to this issue? I am facing the same problem with Zephyr installation.

    note: I am not using Zephyr inside /ncs folder.

    One question is also that the HRS service notification is working then how can it be that custom notification has a issue?