This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I initialize System and PnP ID?

Hi,

I'd like to read PnP and the system ID from Device Information Service. How can I initialize system and PnP ID? Are there any examples how to do this for nrf51822. For example, for the manufacturer name, the function ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, MANUFACTURER_NAME); is used (Keil), are there any for PnP and system ID?

Thx, Adam

  • Here

    static void dis_init(void)
    {
        uint32_t         err_code;
        ble_dis_init_t   discfg;
        ble_dis_pnp_id_t pnp_id;
        ble_dis_sys_id_t sysid;
        char rev[20];
    
        sysid.manufacturer_id = USB_VENDOR_ID;
        sysid.organizationally_unique_id = USB_VENDOR_ID;
    
        pnp_id.vendor_id_source = HID_VENDOR_ID_SOURCE_USB;
        pnp_id.vendor_id        = USB_VENDOR_ID;
        pnp_id.product_id       = USB_PRODUCT_ID;
        pnp_id.product_version  = MODEL_NUM;
    
        memset(&discfg, 0, sizeof(discfg));
    
        ble_srv_ascii_to_utf8(&discfg.manufact_name_str, MANUFACTURER_NAME);
    
        snprintf(rev, 20, "%d.%02d", (HWREV >> 8), HWREV & 0xff);
        ble_srv_ascii_to_utf8(&discfg.hw_rev_str, rev);
    
        snprintf(rev, 20, "%d.%02d", (SWREV >> 8), SWREV & 0xff);
        ble_srv_ascii_to_utf8(&discfg.sw_rev_str, rev);
    
        discfg.p_sys_id = &sysid;
        discfg.p_pnp_id = &pnp_id;
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&discfg.dis_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&discfg.dis_attr_md.write_perm);
    
        err_code = ble_dis_init(&discfg);
        APP_ERROR_CHECK(err_code);
    }
    
  • Thx Nguyen, it works for me ;)

Related