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

Nus profile seems to cause system reset if the data length too long.

iphone5_b.psdm370_android6_b.psdlong_write_error.pngI using SDK11. I porting nus profile to my system and make a customer's UUID. I use Lightblue on iPhone 5 to connect my system. I sent a data through my customer's UUID. My system work fine when the data length is less than or equal 20 bytes. It will cause system reset if the data length is great than 20 bytes. Was the softdevice error, or I made something wrong?

Parents
  • Thank you. Very helpful. Try the following:

    if(p_ble_evt->header.evt_id == BLE_EVT_USER_MEM_REQUEST)
    {
        err_code = sd_ble_user_mem_reply(m_nus.conn_handle, NULL);
        APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->header.evt_id == BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST)
    {
        ble_gatts_rw_authorize_reply_params_t rw_authorize_reply_params;
        
        memset(&rw_authorize_reply_params, 0, sizeof(rw_authorize_reply_params));
        
        rw_authorize_reply_params.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
        
        if(p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL)
        {
            rw_authorize_reply_params.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
        }
        else
        {
            rw_authorize_reply_params.params.write.gatt_status  = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;
        }
        err_code = sd_ble_gatts_rw_authorize_reply(m_nus.conn_handle, &rw_authorize_reply_params);
        APP_ERROR_CHECK(err_code);
    }
    
Reply
  • Thank you. Very helpful. Try the following:

    if(p_ble_evt->header.evt_id == BLE_EVT_USER_MEM_REQUEST)
    {
        err_code = sd_ble_user_mem_reply(m_nus.conn_handle, NULL);
        APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->header.evt_id == BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST)
    {
        ble_gatts_rw_authorize_reply_params_t rw_authorize_reply_params;
        
        memset(&rw_authorize_reply_params, 0, sizeof(rw_authorize_reply_params));
        
        rw_authorize_reply_params.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
        
        if(p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL)
        {
            rw_authorize_reply_params.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
        }
        else
        {
            rw_authorize_reply_params.params.write.gatt_status  = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;
        }
        err_code = sd_ble_gatts_rw_authorize_reply(m_nus.conn_handle, &rw_authorize_reply_params);
        APP_ERROR_CHECK(err_code);
    }
    
Children
No Data
Related