/// © MiroZ 2024

#ifndef __BLE_H__
#define __BLE_H__

#include <stdint.h>
#include <BLEDevice.h>
#include "ReaderWriter.h"
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>

class App;

class Ble : public BLEServerCallbacks, BLECharacteristicCallbacks
{
protected:
	App & m_app;

	char m_name[32];

	BLEServer *m_server = nullptr;
	BLEService *m_service = nullptr;
	BLEAdvertising *m_advertising = nullptr;
	BLECharacteristic *m_characteristic = nullptr;

	ReaderWriter *m_rw = nullptr;

	void onConnect(BLEServer* pServer) override;
	void onDisconnect(BLEServer* pServer) override;
	void onRead(BLECharacteristic *pCharacteristic) override;
	void onWrite(BLECharacteristic *pCharacteristic) override;


public:
	Ble(App & app);
	void start();
};


#endif