Hello.
I'm using nrf52832 (S132 v7.0.1, SDK v17.0.0) to develop peripheral roles.
Setting UUIDs for advertisements, services, and characteristics. At that time, sd_ble_uuid_vs_add and characteristic_add are used a lot, and RAM will be insufficient.
Will you be able to reduce RAM consumption? Below is the current code and specifications.
UUID specifications
Advertisement, service, and characteristic UUIDs should all be different.
Create 18 characteristics. (3 in the code)
// UUID Setting #define ADV_UUID_BASE {0x77, 0x77, 0x66, 0x66, 0x55, 0x55, 0x44, 0x44, 0x33, 0x33, 0x22, 0x22, 0x11, 0x11, 0x00, 0x00} #define SERVICE_UUID_BASE {0xHH, 0xHH, 0xGG, 0xGG, 0xFF, 0xFF, 0xEE, 0xEE, 0xDD, 0xDD, 0xCC, 0xCC, 0xBB, 0xBB, 0xAA, 0xAA} #define CHAR1_UUID_BASE {0xS1, 0xSS, 0xTT, 0xTT, 0xUU, 0xUU, 0xVV, 0xVV, 0xWW, 0xWW, 0xXX, 0xXX, 0xYY, 0xYY, 0xZZ, 0xZZ} #define CHAR2_UUID_BASE {0xS2, 0xSS, 0xTT, 0xTT, 0xUU, 0xUU, 0xVV, 0xVV, 0xWW, 0xWW, 0xXX, 0xXX, 0xYY, 0xYY, 0xZZ, 0xZZ} #define CHAR3_UUID_BASE {0xS1, 0xSS, 0xTT, 0xTT, 0xUU, 0xUU, 0xVV, 0xVV, 0xWW, 0xWW, 0xXX, 0xXX, 0xYY, 0xYY, 0xZZ, 0xZZ} #define BLE_UUID_CHAR_MAX 3 // UUID Base static ble_uuid128_t ble_char_uuid_base[BLE_UUID_CHAR_MAX] = { CHAR1_UUID_BASE, CHAR2_UUID_BASE, CHAR3_UUID_BASE, }; // Characteristic params static ble_add_char_params_t add_char_params = { .uuid = 0xYYYY, .uuid_type = NULL, .max_len = 248, .init_len = 248, .is_var_len = false, .char_props.read = 1, .read_access = SEC_OPEN, }; static uint16_t m_service_handle; /**< Handle of local service (as provided by the BLE stack).*/ static ble_gatts_char_handles_t m_char_handles; /**< Handles of local characteristic (as provided by the BLE stack).*/ // set the UUID here. static void uuid_init(void) { ret_code_t err_code; ble_uuid_t adv_uuid; ble_uuid_t service_uuid; ble_uuid_t char_uuid; ble_uuid128_t adv_uuid_base = {ADV_UUID_BASE}; ble_uuid128_t service_uuid_base = {SERVICE_UUID_BASE}; // advertise setting err_code = sd_ble_uuid_vs_add(&adv_uuid_base, &adv_uuid.type); APP_ERROR_CHECK(err_code); // service setting err_code = sd_ble_uuid_vs_add(&service_uuid_base, &service_uuid.type); APP_ERROR_CHECK(err_code); err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &m_service_handle); APP_ERROR_CHECK(err_code); // characteristic setting for (uint8_t i = 0; i <= BLE_UUID_CHAR_MAX; i++) { err_code = sd_ble_uuid_vs_add(&ble_char_uuid_base[i], &char_uuid.type); APP_ERROR_CHECK(err_code); add_char_params.uuid_type = char_uuid.type; err_code = characteristic_add(m_service_handle, &add_char_params, &m_char_handles); APP_ERROR_CHECK(err_code); } return; }
Happy Holidays!