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

Cannot program nRF51822 again

Dear Sir,

After I remark this //BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); and program it into nRF51822, then I cannot program it again. PC program report it cannot find the device. I believe nRF51822 keep running cause the Jlink cannot connect it.

I also try in the development board PCA10001, the same problem happen!

Please let me know how to resolve it!

static void char_add_server_index(void) { uint32_t err_code; ble_gatts_char_md_t char_md; ble_gatts_attr_md_t cccd_md; ble_gatts_attr_t attr_char_value; ble_uuid_t char_uuid; ble_gatts_attr_md_t attr_md;

memset(&cccd_md, 0, sizeof(cccd_md));

cccd_md.vloc = BLE_GATTS_VLOC_STACK;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
//BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);

memset(&char_md, 0, sizeof(char_md));

char_md.char_props.read   = 1;
char_md.char_props.notify = 1;
char_md.p_char_user_desc       = NULL;
char_md.p_char_pf              = NULL;
char_md.p_user_desc_md         = NULL;
char_md.p_cccd_md              = &cccd_md;
char_md.p_sccd_md              = NULL;

char_uuid.type = BLE_UUID_TYPE_VENDOR_BEGIN + LOCAL_VENDOR_UUID_INDEX;  // Position of the Vender specific ID base in m_base_uuid128.
char_uuid.uuid = SERVER_INDEX;

memset(&attr_md, 0, sizeof(attr_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm);

attr_md.vloc       = BLE_GATTS_VLOC_STACK;
attr_md.rd_auth    = 0;
attr_md.wr_auth    = 0;
attr_md.vlen       = 0;

memset(&attr_char_value, 0, sizeof(attr_char_value));

attr_char_value.p_uuid       = &char_uuid;
attr_char_value.p_attr_md    = &attr_md;
attr_char_value.init_len     = APP_CFG_CHAR_LEN;
attr_char_value.init_offs    = 0;
attr_char_value.max_len      = APP_CFG_CHAR_LEN;
attr_char_value.p_value      = m_char_value;

err_code = sd_ble_gatts_characteristic_add(m_service_handle,
                                        &char_md,
                                        &attr_char_value,
                                        &m_char_handles_is);
APP_ERROR_CHECK(err_code);

}

Related