/*
 * btio.h
 *
 *  Created on: 20 Apr 2015
 *      Author: john
 */

#ifndef BTIO_H_
#define BTIO_H_

#include <klog/klog.h>
#include <kutils/properties.h>

#include "gnxio.h"

class cIO : public cKlog
{

public:
   enum eLedState
   {
	   LED_RED,
	   LED_GREEN,
	   LED_OFF
   };
   static void init(cProperties *);
   static void service();
   static void setLedState(eLedState s);
   static void setLedFlash(bool flash);
   static void setLedOn();
   static void setLedOff();
   static void toggleLed();
   static void setBTReset(bool state);

private:
   cIO(cProperties *);

   static cIO * mInstance;
   int mPairPinIdx;
   int mResetPinIdx;
   int mLedRedIdx;
   int mLedGreenIdx;
   int mGNXIOFd;
   eLedState mLedState;
   bool mLedOn;
   bool mLedFlash;
   int mPairingCtr;


   int lookup_pin(int fd,const char * pin_name);
   int read_pin(int pin_id);
   void set_pin(int pin_id,int pin_state);
   void update_leds();
   void io_update();
};

#endif /* BTIO_H_ */
