Bluetooth: Characteristic Value Showing up as N/A on nRF Connect App

I'm unable to load values into characteristics—they show up as N/A on the nRF Connect app. I tried to enable notifications using the Client Characteristic Configuration, but when I click on the second arrow button (which I think is for enabling notifications, but I could be wrong), I am getting an error that says "Reading is not permitted". I thought I had set the necessary read permissions, but is there something I need to fix here?

This is the function which is passed the value that I want to load into the characteristic:

What I see in the app:

Parents Reply
  • Just realized that you have not implemented the gatt read function for reading the attribute. Please fix your service definition as below 

    static ssize_t read_nfc_feature(struct bt_conn *conn,
    				const struct bt_gatt_attr *attr, void *buf,
    				uint16_t len, uint16_t offset)
    {
    	return bt_gatt_attr_read(conn, attr, buf, len, offset, NULL, 0);
    }
    
    /* Sine Wave Service Declaration */
    BT_GATT_SERVICE_DEFINE(afe_svc,
    	BT_GATT_PRIMARY_SERVICE(BT_UUID_AFE_DATA),
    	BT_GATT_CHARACTERISTIC(BT_UUID_SINE_WAVE,
    				BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY,
    				BT_GATT_PERM_READ, read_nfc_feature, NULL,
    				NULL),
    	BT_GATT_CCC(afe_ccc_cfg_changed,
    			 AFE_GATT_PERM_DEFAULT),
    );

    This should allow your app to read the attribute from nrf connect app. 

Children
Related