#ifndef _DJITELLOWHITE_H
#define _DJITELLOWHITE_H
#include<iostream>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<pthread.h>
#include<cstring>
#include<unistd.h>
/*Library for interacting with DJI Ryze Tello drones.*/


//coding = utf - 8

/*    """C++ wrapper to interact with the Ryze Tello drone using the official Tello api.
    Tello API documentation:
    [1.3](https://dl-cdn.ryzerobotics.com/downloads/tello/20180910/Tello%20SDK%20Documentation%20EN_1.3.pdf)
*/

#define RESPONSE_TIMEOUT 7 //in seconds
#define TAKEOFF_TIMEOUT 20 //in seconds
#define FRAME_GRAB_TIMEOUT 3
#define TIME_BTW_COMMANDS 0.1 //in seconds
#define TIME_BTW_RC_CONTROL_COMMANDS 0.001 //in seconds
#define RETRY_COUNT 3 //number of retries after a failed command


//Video stream, server socket
#define VS_UDP_IP "0.0.0.0"
#define VS_UDP_PORT 11111

#define CONTROL_UDP_PORT 8889
#define STATE_UDP_PORT 8890

#define BUFFER_SIZE 1024
//Constants for video settings
#define BITRATE_AUTO 0
#define BITRATE_1MBPS 1
#define BITRATE_2MBPS 2
#define BITRATE_3MBPS 3
#define BITRATE_4MBPS 4
#define BITRATE_5MBPS 5
#define RESOLUTION_480P "low"
#define RESOLUTION_720P "high"
#define FPS_5 "low"
#define FPS_15 "middle"
#define FPS_30 "high"
#define CAMERA_FORWARD 0
#define CAMERA_DOWNWARD 1
//日志模块暂时不写

class Tello {
private:
	int sock;
	bool stream_on;
	unsigned long host;
public:
	Tello(const char* IP);
	~Tello();
	void set_conf(int socket);
	unsigned long gethost();
	void get_connect(sockaddr_in serveraddr);
	void takeoff(sockaddr_in serveraddr);
	void land(sockaddr_in serveraddr);
	void forward(sockaddr_in serveraddr);
	void back(sockaddr_in serveraddr);
	void left(sockaddr_in serveraddr);
	void right(sockaddr_in serveraddr);
	void up(sockaddr_in serveraddr);
	void down(sockaddr_in serveraddr);
	void cw(sockaddr_in serveraddr);
	void ccw(sockaddr_in serveraddr);
	bool send_message(char* msg,sockaddr_in server_addr,int timeout = RESPONSE_TIMEOUT);
	static void *udp_response_receiver(void* arg);
	void get_video(sockaddr_in serveraddr);

};
// int Telloconnect1(void);



#endif
