2020-03-30 01:44:20 +02:00
|
|
|
/*
|
|
|
|
* NimBLEUtils.h
|
|
|
|
*
|
|
|
|
* Created: on Jan 25 2020
|
|
|
|
* Author H2zero
|
2020-05-14 06:03:56 +02:00
|
|
|
*
|
2020-03-30 01:44:20 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMPONENTS_NIMBLEUTILS_H_
|
|
|
|
#define COMPONENTS_NIMBLEUTILS_H_
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
#if defined(CONFIG_BT_ENABLED)
|
|
|
|
|
|
|
|
#include "host/ble_gap.h"
|
|
|
|
|
2020-06-11 16:13:39 +02:00
|
|
|
/**** FIX COMPILATION ****/
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
/**************************/
|
|
|
|
|
2020-06-11 16:06:16 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void *pATT;
|
|
|
|
TaskHandle_t task;
|
|
|
|
int rc;
|
|
|
|
std::string *buf;
|
|
|
|
} ble_task_data_t;
|
|
|
|
|
2020-03-30 01:44:20 +02:00
|
|
|
extern "C"{
|
|
|
|
char *addr_str(const void *addr);
|
|
|
|
void print_conn_desc(const struct ble_gap_conn_desc *desc);
|
|
|
|
void print_adv_fields(const struct ble_hs_adv_fields *fields);
|
|
|
|
void print_addr(const void *addr);
|
|
|
|
void print_bytes(const uint8_t *bytes, int len);
|
|
|
|
}
|
|
|
|
|
|
|
|
class NimBLEUtils {
|
|
|
|
public:
|
|
|
|
static void dumpGapEvent(ble_gap_event *event, void *arg);
|
|
|
|
static const char* gapEventToString(uint8_t eventType);
|
2020-05-10 15:21:46 +02:00
|
|
|
static char* buildHexData(uint8_t* target, const uint8_t* source, uint8_t length);
|
2020-03-30 01:44:20 +02:00
|
|
|
static const char* advTypeToString(uint8_t advType);
|
|
|
|
static const char* returnCodeToString(int rc);
|
|
|
|
static int checkConnParams(ble_gap_conn_params* params);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CONFIG_BT_ENABLED
|
2020-05-10 15:21:46 +02:00
|
|
|
#endif // COMPONENTS_NIMBLEUTILS_H_
|