/*
 * Copyright 2015 Mario Richter, Peter Stephan
 * This file is part of NeMo.
 *
 * NeMo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * NeMo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with NeMo.  If not, see <http://www.gnu.org/licenses/>.
 */

/*!
 * \file cmd.h
 * \ingroup	cmd
 * \brief	Kommandoverarbeitung - Headerfile
 */


#ifndef CMD_H_
#define CMD_H_


#define CMD_BUFLEN          32                //!< Max. Länge eines Kommandos (Buffergröße)

#define SM_NONE             0                 //!< Untermenü-Index: Hauptmenü
#define SM_SETLIGHTPROG     1                 //!< Untermenü-Index: Lichtprogramm setzen
#define SM_GETLIGHTPROG     2                 //!< Untermenü-Index: Lichtprogramm auslesen
#define SM_GETPROGRAMS      3                 //!< Untermenü-Index: Anzeige aller Lichtprogramme


extern volatile uint8_t subMenu;              //!< Untermenü-Index
extern volatile uint8_t connIndex;            //!< Verbindungsindex (zum Austausch)

extern uint8_t lightProgNr;                   //!< Nummer des aktuellen Lichtprogramms
extern uint8_t lightCmdInd;                   //!< Befehlsnummer innerhalb des Lichtprogramms
extern uint8_t lightBuf[];                    //!< EEPROM-Page-Buffer
extern uint8_t lightBufInd;                   //!< Index innrhalb des EEPROM-Page-Buffers


void tcpCmdHandler(uint8_t ind, uint8_t flag);
void usartCmdHandler(void);
void cmd_init(uint8_t ind);

void sendLine(uint8_t ind, char * str);
void sendLineP(uint8_t ind, const char * str);
void sendString(uint8_t ind, char * str);
void sendStringP(uint8_t ind, const char * str);
void sendHex(uint8_t ind, uint8_t hex, uint8_t upper);
void sendChar(uint8_t ind, char c);

int is_S2_dez(uint8_t s2, uint8_t s3);
int is_S2_hex(uint8_t s2, uint8_t s3);

uint8_t getNewIpAddr(uint8_t * ip);
uint8_t getNewMacAddr(uint8_t * mac);

void finishEEPArrayEntry(void);

char* int2bin(unsigned int, char*);
uint8_t asctohex(char a);


#endif /* CMD_H_ */
