/// © MiroZ 2024

#ifndef __BLE_H__
#define __BLE_H__

#include <stdint.h>
#include <NimBLEDevice.h>
#include "ReaderWriter.h"

class App;

class Ble : public NimBLEServerCallbacks, NimBLECharacteristicCallbacks 
{
protected:
	App & m_app;

	char m_name[32];

	NimBLEServer * m_server = nullptr;
	NimBLEService * m_service = nullptr;
	NimBLECharacteristic * m_characteristic = nullptr;
	NimBLEAdvertising * m_advertising = nullptr;
	ReaderWriter *m_rw = nullptr;

	void onConnect(NimBLEServer* pServer) override;
	void onDisconnect(NimBLEServer* pServer) override;
	void onRead(NimBLECharacteristic* pCharacteristic) override;
	void onWrite(NimBLECharacteristic* pCharacteristic) override;


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


#endif