/*
 * btmodem.h
 *
 *  Created on: 22 Apr 2015
 *      Author: john
 */

#ifndef BTMODEM_H_
#define BTMODEM_H_

#include <klog.h>
#include <hdlc.h>
#include "btcmd.h"

class cBTModem : public cKlog
{
public:
	cBTModem(const char * dev_name);
	void disableDiscovery();
	void enableDiscovery();
	void disableBonding();
	void enableBonding();
	void clearBondingTable();
	void setName(const char * ap_name);
	void getConfig();
	void transmit(uint8_t * buff, int len);
   void transmit_data(uint8_t * tx_buff,int tx_len);
private:

	int mSerialFD;
	bool mDataMode;
	uint8_t mRxBuffer[1024];
	int mRxLen;
	cBTCmd * mCurrCmd;
	int mURCFilterIdx;
	cHDLC mFramer;

	int setup_serial(const char * dev_name);
	void reset_modem();
	void receive();
	void handle_data(uint8_t *buff,int len);
	void handle_cmd_data(uint8_t *str,int len);
	void handle_urc(char *str);

	static void * rx_thread(void *);
};



#endif /* BTMODEM_H_ */
