create EIS service

This commit is contained in:
chain40
2023-05-10 20:23:34 +08:00
parent d0f90da1fd
commit 10aed00a1c
5 changed files with 80 additions and 6 deletions
+3 -1
View File
@@ -83,7 +83,7 @@ extern "C"
// SoftDevice BLE event handler
#define NRF_SDH_BLE_ENABLED 1
// The number of vendor-specific UUIDs.
#define NRF_SDH_BLE_VS_UUID_COUNT 0
#define NRF_SDH_BLE_VS_UUID_COUNT 1
// Attribute Table size in bytes. The size must be a multiple of 4.
#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408
// BLE Observers - Observers and priority levels
@@ -128,12 +128,14 @@ extern "C"
#define MINOR_PRODUCT_NUMBER 4
#define MAJOR_VERSION_NUMBER 1
#define MINOR_VERSION_NUMBER 0
#define BLE_EIS_ENABLED 1
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
#define ELITE_DEVICE_NAME "EIS"
#define MAJOR_PRODUCT_NUMBER 0
#define MINOR_PRODUCT_NUMBER 4
#define MAJOR_VERSION_NUMBER 1
#define MINOR_VERSION_NUMBER 1
#define BLE_EIS_ENABLED 1
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
#define ELITE_DEVICE_NAME "EIS"
#define MAJOR_PRODUCT_NUMBER 0
+1
View File
@@ -163,6 +163,7 @@
</ClCompile>
<ClCompile Include="le_adv.c" />
<ClCompile Include="le_bas.c" />
<ClCompile Include="le_eis_srv.c" />
<ClCompile Include="le_gap.c" />
<ClCompile Include="le_gatt.c" />
<ClCompile Include="le_srv.c" />
+3
View File
@@ -1356,6 +1356,9 @@
<ClCompile Include="le_srv.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="le_eis_srv.c">
<Filter>Source files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="nRF52840_XXAA_S140_reserve.lds">
+65
View File
@@ -0,0 +1,65 @@
#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)
+8 -5
View File
@@ -28,11 +28,11 @@ extern "C"
}
#endif
#define MANUFACTURER_NAME "MEMCHIP" /**< Manufacturer. Will be passed to Device Information Service. */
#define HW_REV STRINGIFY(MAJOR_PRODUCT_NUMBER) "." STRINGIFY(MINOR_PRODUCT_NUMBER) "." STRINGIFY(MAJOR_VERSION_NUMBER) "." STRINGIFY(MINOR_VERSION_NUMBER)
#define FW_REV "0.1.0"
#define SER_NUM "0000-00-00-00001"
#define MODULE_NAME ELITE_DEVICE_NAME
#define MANUFACTURER_NAME "MEMCHIP" /**< Manufacturer. Will be passed to Device Information Service. */
#define HW_REV STRINGIFY(MAJOR_PRODUCT_NUMBER) "." STRINGIFY(MINOR_PRODUCT_NUMBER) "." STRINGIFY(MAJOR_VERSION_NUMBER) "." STRINGIFY(MINOR_VERSION_NUMBER)
#define FW_REV "0.1.0"
#define SER_NUM "0000-00-00-00001"
#define MODULE_NAME ELITE_DEVICE_NAME
static void le_dis_init(void)
{
@@ -53,4 +53,7 @@ static void le_dis_init(void)
void le_srv_init(void)
{
le_dis_init();
extern void le_eis_init(void);
le_eis_init();
}