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
  • Use "nrf Connect" to connect with your device ,then check if there is an unknown service has the same uuid with yours.

    It seems that you are adding a vendor defined uuid .You should describe your question more detailed. You don't see this service ,by scanning or connecting ? If scan ,you should add uuid to advertising packet, if connected, you should check your initialization procedure.

    Hi: I don't think it's right. ----> #define BLE_UUID 0x0005 Look at this defination : uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */

    If your UUID is true service uuid,the right value should be 0x0000 , 12-13 of 128-bit UUID. But you can see that ,its name is NUS_BASE_UUID. You know? It's a basal uuid.

    12-13 of nus service is defined by nordic ,you can not change it . As I know , ble uart service's (nus) UUID is 0x0001

    #define BLE_UUID_NUS_SERVICE 0x0001
    #define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0002/**< The UUID of the TX Characteristic. */
    #define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0003 /**< The UUID of the RX Characteristic.*/
    
Reply
  • Use "nrf Connect" to connect with your device ,then check if there is an unknown service has the same uuid with yours.

    It seems that you are adding a vendor defined uuid .You should describe your question more detailed. You don't see this service ,by scanning or connecting ? If scan ,you should add uuid to advertising packet, if connected, you should check your initialization procedure.

    Hi: I don't think it's right. ----> #define BLE_UUID 0x0005 Look at this defination : uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */

    If your UUID is true service uuid,the right value should be 0x0000 , 12-13 of 128-bit UUID. But you can see that ,its name is NUS_BASE_UUID. You know? It's a basal uuid.

    12-13 of nus service is defined by nordic ,you can not change it . As I know , ble uart service's (nus) UUID is 0x0001

    #define BLE_UUID_NUS_SERVICE 0x0001
    #define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0002/**< The UUID of the TX Characteristic. */
    #define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0003 /**< The UUID of the RX Characteristic.*/
    
Children
No Data
Related