This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Error 133 (0x85): GATT ERROR with custom service tutorial

Hello,

I am new to the Nordic Environment. I am following the excellent tutorial to create a custom service and characteristic.

Everything worked fine until Step 6(Handling the Write event from soft device). 

However, after working on Step 7 & 8(Propagating Custom Service Events to Application and Notifying the Custom Value Characteristic), I get Error 133: GATT ERROR on the nRF Connect app (on a One Plus 5) when I try to connect to the advertised label. 

I have read the other posts related to this issue but can't my sense of them with respect to my case.  What could be the reason for sudden occurrence of this error?

Please help.

Thanks

  • I have zeroed down the problem further. After I commented out the lines as shown below in the on_connect() function, the error goes away and I can connect again. Can anybody help with explaining what those lines might be doing to introduce the GATT ERROR?

    /**@brief Function for handling the Connect event.
     *
     * @param[in]   p_cus       Custom Service structure.
     * @param[in]   p_ble_evt   Event received from the BLE stack.
     */
    
    static void on_connect(ble_cus_t * p_cus, ble_evt_t const * p_ble_evt)
    {
        p_cus->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    
        //ble_cus_evt_t evt;             
    
        //evt.evt_type = BLE_CUS_EVT_CONNECTED;
    
        //p_cus->evt_handler(p_cus, &evt);
    }

  •  I have followed your excellent tutorial on developing a custom service. However as soon as I invoke the event handler from ble_cus.c by calling p_cus->evt_handler(p_cus, &evt), I get a GATT ERROR when trying to connect from the app. What could be happening? I would greatly appreciate your help. Thanks

  • Hi RO, have you added the line that sets on_cus_evt as the event handler in services_init() as shown below?

            // Initialize CUS Service init structure to zero.
            ble_cus_init_t      cus_init = {0};
    
            // Set Custom Service Event handler
            cus_init.evt_handler                = on_cus_evt;
        
            BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.cccd_write_perm);
            BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.read_perm);
            BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.write_perm);
        
            err_code = ble_cus_init(&m_cus, &cus_init);
            APP_ERROR_CHECK(err_code);

  • Yes I did. the error still appears. For the time being, I am invoking the event handler in on_write() function only, and it works. But it doesn't work when I invoke it in the on_connect() function. 

  • cccd_md.write_perm = p_cus_init->custom_value_char_attr_md.cccd_write_perm;

    Did you add this line to the custom_value_char_add() function in ble_cus.c

Related