34 lines
1.0 KiB
C
34 lines
1.0 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "host/ble_gatt.h"
|
|
|
|
#define CHAR_PRESENTATION_FORMAT_SIZE 7
|
|
|
|
struct char_pres_format {
|
|
uint8_t format;
|
|
uint8_t exponent;
|
|
uint16_t unit;
|
|
uint8_t namespc;
|
|
uint8_t descrH;
|
|
uint8_t descrL;
|
|
};
|
|
|
|
struct dsc_content {
|
|
size_t data_size;
|
|
void* data;
|
|
};
|
|
|
|
typedef void (*charReadCallback)(int svc_ind, int chr_ind, void** value, size_t* value_size);
|
|
typedef int (*charWriteCallback)(int svc_ind, int chr_ind, struct os_mbuf* om);
|
|
typedef void (*dscReadCallback)(int svc_ind, int chr_ind, void** value, size_t* value_size);
|
|
|
|
void initBLE(char* name);
|
|
void ble_advertise(void);
|
|
void set_gatt_services(struct ble_gatt_svc_def* svcs, uint16_t num);
|
|
void print_service(struct ble_gatt_svc_def* svcs);
|
|
void notify(uint16_t svc_ind, uint16_t chr_ind, void* value, size_t value_size);
|
|
void set_on_char_read_handler(charReadCallback cb);
|
|
void set_on_char_write_handler(charWriteCallback cb);
|
|
int gatt_svr_chr_write_get_data(struct os_mbuf *om, uint16_t min_len, uint16_t max_len, void *dst, uint16_t *len); |