66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
#include "sdk_common.h"
|
|
#if NRF_MODULE_ENABLED(BLE_EIS)
|
|
|
|
#include "app_error.h"
|
|
#include "ble_gatts.h"
|
|
#include "ble_srv_common.h"
|
|
#include "nrf_sdh_ble.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
/**< Used vendor specific UUID. */
|
|
#define BLE_EIS_BASE_UUID \
|
|
{ \
|
|
{ \
|
|
0x4D, 0x3C, 0x56, 0x45, 0x12, 0x8B, 0x44, 0x1D, 0x8D, 0x6F, 0xC5, 0x95, 0x00, 0x00, 0x9B, 0xD8 \
|
|
} \
|
|
}
|
|
#define BLE_UUID_EIS_SERVICE 0x0001
|
|
|
|
typedef struct
|
|
{
|
|
uint16_t conn_handle;
|
|
uint16_t service_handle;
|
|
} ble_eis_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint16_t battery_volt;
|
|
} ble_eis_init_t;
|
|
|
|
static ble_eis_t ble_eis;
|
|
|
|
static uint32_t ble_eis_init(ble_eis_init_t const *p_eis_init)
|
|
{
|
|
uint32_t err_code;
|
|
ble_uuid128_t base_uuid = BLE_EIS_BASE_UUID;
|
|
ble_uuid_t ble_uuid = {
|
|
.type = BLE_UUID_TYPE_UNKNOWN,
|
|
.uuid = BLE_UUID_EIS_SERVICE,
|
|
};
|
|
|
|
// Adding vendor specific UUID to the SoftDevice
|
|
err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
|
|
APP_ERROR_CHECK(err_code);
|
|
|
|
// Adding proprietary service to the SoftDevice
|
|
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &ble_eis.service_handle);
|
|
APP_ERROR_CHECK(err_code);
|
|
|
|
return NRF_SUCCESS;
|
|
}
|
|
|
|
void le_eis_init(void)
|
|
{
|
|
ble_eis_init_t eis_init;
|
|
memset(&eis_init, 0x00, sizeof(eis_init));
|
|
|
|
extern uint16_t bas_volt_read(void);
|
|
eis_init.battery_volt = bas_volt_read();
|
|
ret_code_t err_code = ble_eis_init(&eis_init);
|
|
APP_ERROR_CHECK(err_code);
|
|
}
|
|
|
|
#endif // NRF_MODULE_ENABLED(BLE_EIS)
|