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
BT_GATT_SERVICE_DEFINE(vnd_svc,
BT_GATT_PRIMARY_SERVICE(&vnd_uuid), //0

//force characteristic
BT_GATT_CHARACTERISTIC(&force_uuid.uuid, BT_GATT_CHRC_NOTIFY | BT_GATT_CHRC_WRITE, //1
BT_GATT_PERM_WRITE,
NULL, write_force, force_value),

BT_GATT_CCC(force_ccc_cfg_changed, BT_GATT_PERM_WRITE), //2

//ROM characteristic
BT_GATT_CHARACTERISTIC(&rom_uuid.uuid, BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY | BT_GATT_CHRC_WRITE, //3
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
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

Related