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

added service nRF51 SDK9

I added service into ble_app_template

in static void services_init(void) {}

like this

#define NUS_BASE_UUID {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}}

#define BLE_UUID			0x0005 

ble_uuid128_t base_uuid = NUS_BASE_UUID;   
ble_uuid_t    ble_uuid = { . uuid = BLE_UUID }; 
uint32_t 	  err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
APP_ERROR_CHECK(err_code);

uint16_t      service_handle;		  
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &service_handle);  
APP_ERROR_CHECK(err_code);	

sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_TAG);

Why I don't see in my smartfone this service added?

Parents
  • Thanks for answer. There are two projects in examples (SDK9): 1- ble_app_uart_s130 I call

    services_init();
    

    where I call

    err_code = ble_nus_init(&m_nus, &nus_init);
    

    where I added UUID

    ble_uuid128_t nus_base_uuid = NUS_BASE_UUID;
    ...
    err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
    

    And at this case I can observer on my smartfone (central role) this UUID when discovered.

    2- In those examples we have ble_app_template where I insert same code like previwes example into

    static void services_init(void)
    {
        /* YOUR_JOB: Add code to initialize the services used by the application.
        uint32_t                           err_code;
        ble_xxs_init_t                     xxs_init;
        ble_yys_init_t                     yys_init;
    
        // Initialize XXX Service.
        memset(&xxs_init, 0, sizeof(xxs_init));
    
        xxs_init.evt_handler                = NULL;
        xxs_init.is_xxx_notify_supported    = true;
        xxs_init.ble_xx_initial_value.level = 100; 
        
        err_code = ble_bas_init(&m_xxs, &xxs_init);
        APP_ERROR_CHECK(err_code);
    
        // Initialize YYY Service.
        memset(&yys_init, 0, sizeof(yys_init));
        yys_init.evt_handler                  = on_yys_evt;
        yys_init.ble_yy_initial_value.counter = 0;
    
        err_code = ble_yy_service_init(&yys_init, &yy_init);
        APP_ERROR_CHECK(err_code);
        */
    			
    	ble_uuid128_t base_uuid = NUS_BASE_UUID;   
    	ble_uuid_t    ble_uuid = { . uuid = BLE_UUID }; 
        uint32_t 	  err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
        APP_ERROR_CHECK(err_code);
      
    	uint16_t      service_handle;		  
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &service_handle);  
        APP_ERROR_CHECK(err_code);	
    	
    	sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_TAG);
    }
    

    but now I can't see on my smartfone same service. Why?

Reply
  • Thanks for answer. There are two projects in examples (SDK9): 1- ble_app_uart_s130 I call

    services_init();
    

    where I call

    err_code = ble_nus_init(&m_nus, &nus_init);
    

    where I added UUID

    ble_uuid128_t nus_base_uuid = NUS_BASE_UUID;
    ...
    err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
    

    And at this case I can observer on my smartfone (central role) this UUID when discovered.

    2- In those examples we have ble_app_template where I insert same code like previwes example into

    static void services_init(void)
    {
        /* YOUR_JOB: Add code to initialize the services used by the application.
        uint32_t                           err_code;
        ble_xxs_init_t                     xxs_init;
        ble_yys_init_t                     yys_init;
    
        // Initialize XXX Service.
        memset(&xxs_init, 0, sizeof(xxs_init));
    
        xxs_init.evt_handler                = NULL;
        xxs_init.is_xxx_notify_supported    = true;
        xxs_init.ble_xx_initial_value.level = 100; 
        
        err_code = ble_bas_init(&m_xxs, &xxs_init);
        APP_ERROR_CHECK(err_code);
    
        // Initialize YYY Service.
        memset(&yys_init, 0, sizeof(yys_init));
        yys_init.evt_handler                  = on_yys_evt;
        yys_init.ble_yy_initial_value.counter = 0;
    
        err_code = ble_yy_service_init(&yys_init, &yy_init);
        APP_ERROR_CHECK(err_code);
        */
    			
    	ble_uuid128_t base_uuid = NUS_BASE_UUID;   
    	ble_uuid_t    ble_uuid = { . uuid = BLE_UUID }; 
        uint32_t 	  err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
        APP_ERROR_CHECK(err_code);
      
    	uint16_t      service_handle;		  
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &service_handle);  
        APP_ERROR_CHECK(err_code);	
    	
    	sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_TAG);
    }
    

    but now I can't see on my smartfone same service. Why?

Children
No Data
Related