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

How to discover custom service of peripheral

Hi, Nordic staff.

I'm working with Central device using S132.

There is a peripheral device using S112 in Nordic. I didn't make this peripheral.

My question is that is it possible to discover above service and some characteristics uuid from S132 central?

If possible, can tell me how should I do?

Best regards.

Parents
  • Do you know the service UUID & char. in peripheral side? If yes, you may define it in your code. If not, you may sniff the peripheral and try the service UUID and the characteristics data format. Sometimes the service UUID will be in advertisement data package.

  • Defined as "ble_nus_c_evt_handler"

    static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_ble_nus_evt)
    {
        ret_code_t err_code;
    
        switch (p_ble_nus_evt->evt_type)
        {
             
            case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:
                printf("Discovery complete.");
                err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
                APP_ERROR_CHECK(err_code);
    
                err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);
                APP_ERROR_CHECK(err_code);
                printf("Connected to device with Nordic UART Service.");
                break;
    
            case BLE_NUS_C_EVT_NUS_TX_EVT:
                ble_nus_chars_received_uart_print(p_ble_nus_evt->p_data, p_ble_nus_evt->data_len);
                printf("BLE_NUS_C_EVT_NUS_TX_EVT\n");
                break;
    
            case BLE_NUS_C_EVT_DISCONNECTED:
                printf("Disconnected.");
                scan_start();
                break;
            default:
                printf("client evt handler\r");
                break;
        }
    }

    "nus_c_evt_handler" is used in "nus_c_init".

    static void nus_c_init(void)
    {
        ret_code_t       err_code;
        ble_nus_c_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.evt_handler   = ble_nus_c_evt_handler;
        init.error_handler = nus_error_handler;
        init.p_gatt_queue  = &m_ble_gatt_queue;
    
        
        err_code = ble_nus_c_init(&m_ble_nus_c, &init);
        APP_ERROR_CHECK(err_code);
    }

Reply
  • Defined as "ble_nus_c_evt_handler"

    static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_ble_nus_evt)
    {
        ret_code_t err_code;
    
        switch (p_ble_nus_evt->evt_type)
        {
             
            case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:
                printf("Discovery complete.");
                err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
                APP_ERROR_CHECK(err_code);
    
                err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);
                APP_ERROR_CHECK(err_code);
                printf("Connected to device with Nordic UART Service.");
                break;
    
            case BLE_NUS_C_EVT_NUS_TX_EVT:
                ble_nus_chars_received_uart_print(p_ble_nus_evt->p_data, p_ble_nus_evt->data_len);
                printf("BLE_NUS_C_EVT_NUS_TX_EVT\n");
                break;
    
            case BLE_NUS_C_EVT_DISCONNECTED:
                printf("Disconnected.");
                scan_start();
                break;
            default:
                printf("client evt handler\r");
                break;
        }
    }

    "nus_c_evt_handler" is used in "nus_c_init".

    static void nus_c_init(void)
    {
        ret_code_t       err_code;
        ble_nus_c_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.evt_handler   = ble_nus_c_evt_handler;
        init.error_handler = nus_error_handler;
        init.p_gatt_queue  = &m_ble_gatt_queue;
    
        
        err_code = ble_nus_c_init(&m_ble_nus_c, &init);
        APP_ERROR_CHECK(err_code);
    }

Children
No Data
Related