I'm sorry but i don't know where else to turn. The tutorial on adding a characteristic to a service (the nordic tutorial i am basing this off) isn't finished and I have no one to ask but the internet. I have tried copying code and applying it myself but there's always some problem that never gets it working.
I can make a service just fine because of [this] (devzone.nordicsemi.com/.../) tutorial and I understand all the steps for making a characteristic, at least i am pretty sure I do, but I can't seem to figure out how to put the code in the right place. I have my main, service_maker.c, and service_maker.h
I really need help. I've been at this for too long and its driving me insane. I tried comparing to to other code but the functions are either return uint32_t or lead to other functions that involve things I simply don't have the time to learn. Please help.
main service init()
static void services_init(void)
{
our_service_init(&main_ble_oss_char_type);
{
service_maker.c
void our_service_init2(ble_oss_char_type * p_our_service)
{
uint32_t err_code; // Variable to hold return codes from library and softdevice functions
ble_uuid_t service_uuid;
ble_uuid128_t base_uuid = BLE_UUID_OUR_BASE_UUID;
service_uuid.uuid = BLE_UUID_OUR_SERVICE;
err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
APP_ERROR_CHECK(err_code);
// OUR_JOB: Declare 16 bit service and 128 bit base UUIDs and add them to BLE stack table
// OUR_JOB: Add our service
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
&service_uuid,
&p_our_service->service_handle);
}
void our_char_add(ble_oss_char_type * p_our_service){
uint32_t err_code;
ble_uuid_t char_uuid;
ble_uuid128_t base_uuid = BLE_UUID_OUR_BASE_UUID;
char_uuid.uuid = BLE_UUID_OUR_CHARACTERISTC_UUID;
sd_ble_uuid_vs_add(&base_uuid, &char_uuid.type);
APP_ERROR_CHECK(err_code);
ble_gatts_attr_md_t attr_md;
memset(&attr_md, 0, sizeof(attr_md));
attr_md.vloc = BLE_GATTS_VLOC_STACK;
ble_gatts_attr_t attr_char_value;
memset(&attr_char_value, 0, sizeof(attr_char_value));
attr_char_value.p_uuid = &char_uuid;
attr_char_value.p_attr_md = &attr_md;
ble_gatts_char_md_t char_md;
err_code = sd_ble_gatts_characteristic_add(p_our_service->service_handle,
&char_md,
&attr_char_value,
&p_our_service->char_handles);
APP_ERROR_CHECK(err_code);
}
and then service_maker.h
typedef struct ble_oss ble_oss_char_type;
struct ble_oss
{
uint16_t conn_handle; //< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection).
uint16_t service_handle; //< Handle of Our Service (as provided by the BLE stack).
// OUR_JOB: Add handles for our characteristic
ble_gatts_char_handles_t char_handles;
};
void our_service_init(ble_oss_char_type * p_our_service);
void our_char_add(ble_oss_char_type * p_our_service);
I know I can't be the only one out there who could benefit from a good answer here. Thank you so much and i really appreciate any help you offer