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_
|
2021-09-07 05:14:43 +02:00
|
|
|
|
|
|
|
#include "nimconfig.h"
|
2020-03-30 01:44:20 +02:00
|
|
|
#if defined(CONFIG_BT_ENABLED)
|
|
|
|
|
2024-11-03 02:00:07 +01:00
|
|
|
# include <freertos/FreeRTOS.h>
|
|
|
|
# include <freertos/task.h>
|
2020-06-11 16:13:39 +02:00
|
|
|
|
2020-06-11 16:06:16 +02:00
|
|
|
#include <string>
|
|
|
|
|
2024-11-03 00:56:23 +01:00
|
|
|
class NimBLEAddress;
|
|
|
|
|
2024-11-03 02:00:07 +01:00
|
|
|
struct BleTaskData {
|
|
|
|
void* pATT;
|
2020-06-11 16:06:16 +02:00
|
|
|
TaskHandle_t task;
|
2024-11-03 02:00:07 +01:00
|
|
|
int rc;
|
|
|
|
void* buf;
|
|
|
|
};
|
2020-06-11 16:06:16 +02:00
|
|
|
|
2024-11-03 02:00:07 +01:00
|
|
|
struct ble_gap_event;
|
2020-07-09 03:27:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief A BLE Utility class with methods for debugging and general purpose use.
|
|
|
|
*/
|
2020-03-30 01:44:20 +02:00
|
|
|
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);
|
2024-11-03 00:56:23 +01:00
|
|
|
static NimBLEAddress generateAddr(bool nrpa);
|
2020-03-30 01:44:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIG_BT_ENABLED
|
2020-05-10 15:21:46 +02:00
|
|
|
#endif // COMPONENTS_NIMBLEUTILS_H_
|