WXK
2025-01-21 8f1a91a8ec98e430cfe4357bda099d495917198e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
 *******************************************************************************
 * @file     app_ble_svr.c
 * @create   2023-08-01    
 * @author   Panchip BLE GROUP
 * @note
 * Copyright (c) 2022 Shanghai Panchip Microelectronics Co.,Ltd.
 *
 *******************************************************************************
 */
#include <string.h>
 
#include "pan_ble.h"
#include "app_log.h"
#include "app_ble_svr.h"
 
void app_ble_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg)
{
    char buf[BLE_UUID_STR_LEN];
 
    switch (ctxt->op) {
    case BLE_GATT_REGISTER_OP_SVC:
        APP_LOG_INFO("registered service %s with handle=%d\n",
                    ble_uuid_to_str(ctxt->svc.svc_def->uuid, buf),
                    ctxt->svc.handle);
        break;
 
    case BLE_GATT_REGISTER_OP_CHR:
        APP_LOG_INFO("  -registering characteristic %s with "
                           "def_handle=%d val_handle=%d\n",
                    ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf),
                    ctxt->chr.def_handle,
                    ctxt->chr.val_handle);
        break;
 
    case BLE_GATT_REGISTER_OP_DSC:
        APP_LOG_INFO("    -registering descriptor %s with handle=%d\n",
                    ble_uuid_to_str(ctxt->dsc.dsc_def->uuid, buf),
                    ctxt->dsc.handle);
        break;
 
    default:
        app_assert(0);
        //break;
    }
}
 
void app_ble_svc_init(void)
{
    /* register DIS services */
    ble_svc_dis_init();
    
    /* register HRS services */
    ble_svc_hrs_init();
    
    /* register call-back */
    ble_hs_cfg.gatts_register_cb  = app_ble_svr_register_cb;
    ble_hs_cfg.gatts_register_arg = NULL;
}