Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
121:ee02790d00b7
Parent:
119:ee6a53069455
Child:
123:1d395b5a4cad
--- a/call_box.h	Mon May 04 17:25:29 2015 +0000
+++ b/call_box.h	Fri May 08 04:15:23 2015 +0000
@@ -9,13 +9,12 @@
 #ifndef __CALL_BOX_H__
 #define __CALL_BOX_H__
 
-#include "mbed.h"
+#include <stdint.h>
 #include "object.h"
 #include "sip.h"
-#include "debug.h"
-#include "shared_variables.h"
 
 const int __RESQUEST_TIME__ = 3;
+
 const uint16_t MAX_INVITE_RETRY = 512 * 2;
 
 const uint8_t __TIMEOUT__  = 250;
@@ -24,47 +23,73 @@
 const uint8_t __RANGE_TO_REGISTER__ = 150;
 ///< Doc. later
 const uint8_t __TIME_TO_REGISTER__ = __TIMEOUT__ - __RANGE_TO_REGISTER__;
+
 const uint8_t __CYCLES__ = __TIME_TO_REGISTER__ / __RESQUEST_TIME__; // 200 // 3 ~ 66
+
 const uint8_t RTP_REQUEST_PORT_TIMEOUT = 45;
 
 const short int REQUEST_REGISTRY = -1;
 const short int REQUEST_PEND = -2;
 const short int REQUEST_PING = -4;
+///< Valor usado como referencia para registro do equipamento CBx.
 
-///< Valor usado como referencia para registro do equipamento CBx.
 const uint8_t __MAX_ATTEMPTS__  = 5;
 ///< O numero maximo de vezes que a Header vai tentar pingar o Call_Box
+
 const uint8_t __STEP__ = 30;
 ///< Usado para aumentar o intervalo entre cada ping, fora de uso atualmente.
+
 const uint8_t __MAX_TIMEOUT__ = __STEP__ * __MAX_ATTEMPTS__;
 ///< Usado para limitar o tempo maximo de timeout do Call_Box sem responder o ping, fora de uso.
 
 const uint8_t cb_idle = 1;
 ///< Representa que o Call_Box esta disponivel
+
 const uint8_t cb_ringing = 2;
 ///< Representa o Call_Box no status, discando.
+
 const uint8_t cb_trying = 3;
 ///< Representa o Call_Box no status tentando concluir o pedido de ligação.
+
 const uint8_t cb_on_call = 4;
 ///< Representa que o Call_Box já esta em uma ligação.
+
 const uint8_t cb_busy = 5;
 ///< Representa que o Call_Box esta ocupado.
+
 const uint8_t cb_denied = 6;
 ///< Representa que o pedido de invite do Call_Box foi negado.
+
 const uint8_t cb_bootloader = 7;
 ///< Representa que o Call_Box esta em atualizacao de firmware  
 
 
-class Call_Box : public Object{
+class Call_Box : public Object {
     private :
+        /**
+          * @Synopsis Objeto Sip que será usado para tratativas com o servidor.
+          *
+          * \note Esse objeto é criado no construtor da classe Call_Box, com os mesmos parâmetros passados para o 
+          * construtor da classe Call_Box.
+          */
+        Sip * sip;
+    
         bool invite_response;
         bool bye_response;
+        bool overflow;
         
         int ext;  // ramal
         int port; // porta
         int sip_socket_fd;
         int shift_port;
         
+        /**
+          * @Synopsis Representa o status do Call_Box.
+          *
+          * \note Este valor sempre é atualizado ( por convenção ) com o uso da macro set_status(a,b), definida em utils.h
+          */
+        uint8_t status;
+        
         uint8_t remaining_attempts;
         uint8_t msg_id;
         uint8_t timeslice;
@@ -73,6 +98,7 @@
         
         uint16_t invite_retry_count;
         
+        //FIXME remove timeout
         float timeout;
         
         Timer t;
@@ -80,14 +106,6 @@
         Timer invite_timer;
     public :
                 /**
-                 * @Synopsis Objeto Sip que será usado para tratativas com o servidor.
-                 *
-                 * \note Esse objeto é criado no construtor da classe Call_Box, com os mesmos parâmetros passados para o 
-                 * construtor da classe Call_Box.
-                 */
-        Sip * sip;
-                
-                /**
                  * @Synopsis Cria um objeto Call_Box
                  *
                  * @param ext Vincula o objeto ao ramal informado
@@ -102,7 +120,7 @@
                  * ...
                  * @endcode
                  */
-        Call_Box( int ext, int port );
+        Call_Box ( const int ext, const int port );
 
                 /**
                  * @Synopsis Destroi o objeto Call_Box
@@ -115,14 +133,7 @@
                  * @endcode
                  * \note Deleta o objeto Sip nesse processo.
                  */
-        ~Call_Box( void );
-        
-                /**
-                 * @Synopsis Representa o status do Call_Box.
-                 *
-                 * \note Este valor sempre é atualizado ( por convenção ) com o uso da macro set_status(a,b), definida em utils.h
-                 */
-        uint8_t status;
+        ~Call_Box ( void );
         
                 /**
                  * @Synopsis Informa o ramal vinculado ao objeto Call_Box.
@@ -136,7 +147,7 @@
                  * ...
                  * @endcode
                  */
-        int get_ext( void );
+        int get_ext ( void );
 
                 /**
                  * @Synopsis Informa o numero da porta vinculada ao objeto Call_Box.
@@ -150,7 +161,7 @@
                  * ...
                  * @endcode
                  */
-        int get_port( void );
+        int get_port ( void );
        
                 /**
                  * @Synopsis Informa o tempo decorrido.
@@ -165,7 +176,7 @@
                  * ...
                  * @endcode
                  */
-        float get_elapsed_time( void );
+        float get_elapsed_time ( void );
 
                 /**
                  * @Synopsis Reseta o timer do objeto Call_Box.
@@ -177,7 +188,7 @@
                  * ...
                  * @endcode
                  */
-        void reset_elapsed_time( void );
+        void reset_elapsed_time ( void );
 
                 /**
                  * @Synopsis Invoca o método de registro deste Call_Box ( via objeto Sip vinculado ).
@@ -189,7 +200,7 @@
                  * ...
                  * @endcode
                  */
-        void registry( void );
+        void registry ( void );
 
                 /**
                  * @Synopsis Invoca o método de pedido de ligação.
@@ -204,7 +215,7 @@
                  * ...
                  * @endcode
                  */
-        VZ_call * invite( void );
+        VZ_call * invite ( void );
 
                 /**
                  * @Synopsis Valor inicial para preenchimento deste campo nos pacotes trocados entre Header/Call_Box.
@@ -218,7 +229,7 @@
                  * ...
                  * @endcode
                  */
-        void set_msg_id( uint8_t msg_id );
+        void set_msg_id ( const uint8_t msg_id );
 
                 /**
                  * @Synopsis Informa o numero atual de msg_id que será enviado na próxima mensagem desse Call_Box
@@ -232,7 +243,7 @@
                  * ...
                  * @endcode
                  */
-        uint8_t get_msg_id( void );
+        uint8_t get_msg_id ( void );
 
         
                 /**
@@ -248,7 +259,7 @@
                  * ...
                  * @endcode
                  */
-        void set_timeslice( uint8_t timeslice );
+        void set_timeslice ( const uint8_t timeslice );
 
                 /**
                  * @Synopsis Informa o timeslice ocupado atualmente pelo Call_Box.
@@ -262,9 +273,7 @@
                  * ...
                  * @endcode
                  */
-        uint8_t get_timeslice( void );
-
-        //void set_sip( Sip * sip );
+        uint8_t get_timeslice ( void );
                 
                 /**
                  * @Synopsis Faz chamada ( via objeto Sip vinculado ) a função que irá escutar a porta SIP associada neste Call_Box.
@@ -280,19 +289,7 @@
                  * ...
                  * @endcode
                  */
-        int listen_SIP_server( void );
-
-                /**
-                 * @Synopsis Invoca ( no objeto Sip ) o método de pedido de "desregistro".
-                 *
-                 * Exemplo:
-                 * @code
-                 * ...
-                 *  cb->unregistry();
-                 * ...
-                 * @endcode
-                 */
-        void unregistry( void );
+        int listen_SIP_server ( void );
 
                 /**
                  * @Synopsis Invoca ( via objeto Sip ) o método de envio do pacote de "bye" para o servidor.
@@ -304,7 +301,7 @@
                  * ...
                  * @endcode
                  */
-        void send_bye( void );
+        void send_bye ( void );
 
                 /**
                  * @Synopsis Destroi o objeto Sip vinculado ao Call_Box, criando e vinculando outro em seguida.
@@ -316,7 +313,7 @@
                  * ...
                  * @endcode
                  */
-        void reset_sip( void );
+        void reset_sip ( void );
 
                 /**
                  * @Synopsis Altera o valor do status do objeto Sip vinculado.
@@ -330,49 +327,83 @@
                  * ...
                  * @endcode
                  */
-        void set_sip_status( int status );
+        void set_sip_status ( const int status );
         
         /*------------------------------------------------------------------------------------------------*/
-        bool get_invite_response( void );
-        bool get_bye_response( void );
+        bool get_invite_response ( void );
+        
+        bool get_bye_response ( void );
+        
         bool time_to_retry ( void );
+        
         bool is_rtp_timer_timeout ( void );
         
-        int get_sip_status( void );
-        int set_sip_status( uint8_t sip_status );
-        int get_status( void );
-        int get_sip_ext( void );
-        int get_sip_port( void );
-        int get_timer( void );
+        bool get_overflow_flag ( void );
+        
+        
+        uint8_t get_invite_try_number ( void );
+        
+        uint8_t msg_id_update ( void );
+        
+        uint16_t get_invite_retry_count ( void );
+        
+        
+        int get_sip_status ( void );
+        
+        void set_sip_status ( const uint8_t sip_status );
+        
+        int get_status ( void );
+        
+        int get_sip_ext ( void );
+        
+        int get_sip_port ( void );
+        
+        int get_timer ( void );
+        
         int get_rtp_port ( void );
+        
         int print_yourself ( void );
-        int get_sip_socket_fd( void );
-        int sip_udp_incomming_pkg( void );
+        
+        int get_sip_socket_fd ( void );
+        
+        int sip_udp_incomming_pkg ( void );
+        
         int get_rtp_timer ( void );
-        int call_init ( int timeslice );
-        int call_end ( bool send_bye_to_ast = true  );
+        
+        int call_init ( const int timeslice );
+        
+        int call_end ( const bool send_bye_to_ast = true  );
+        
         int call_confirmed ( void );
+        
         int retry_send_invite_pkg_to_ast ( void );
         
-        void cb_set_status( uint8_t status );
-        void set_invite_response_ok( void );
-        void set_invite_response_pending( void );
+        int sip_print_yourself ( void );
+        
+        
+        void cb_set_status ( const uint8_t status );
         
-        void set_bye_response_ok( void );
-        void set_bye_response_pending( void );
+        void set_invite_response_ok ( void );
+        
+        void set_invite_response_pending ( void );
         
-        void reset_cb_status( void );
-        void invite_retry_count_reset( void );
+        void set_bye_response_ok ( void );
+        
+        void set_bye_response_pending ( void );
         
-        uint8_t get_invite_try_number ( void );
-        uint8_t msg_id_update ( void );
+        void reset_cb_status ( void );
         
-        uint16_t get_invite_retry_count( void );
+        void invite_retry_count_reset ( void );
+              
+        void set_rtp_port ( const int new_rtp_port );
         
-        void set_rtp_port ( int );
         void init_rtp_timer ( void );
+        
         void reset_rtp_timer ( void );
-        void call_config ( void );        
+        
+        void call_config ( void ); 
+        
+        Sip * get_sip ( void );
 };
 
 #endif
\ No newline at end of file