Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Revision 50:d9b6577a70f5, committed 2014-10-20
- Comitter:
- klauss
- Date:
- Mon Oct 20 19:28:38 2014 +0000
- Parent:
- 49:4837ed2aad6b
- Child:
- 51:5fc3a8f02fdf
- Commit message:
- pcb ext cmd - implementado
Changed in this revision
--- a/EthernetInterface.lib Mon Oct 20 16:32:12 2014 +0000 +++ b/EthernetInterface.lib Mon Oct 20 19:28:38 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/VZTECH/code/EthernetInterface/#04085b5afb90 +http://mbed.org/teams/VZTECH/code/EthernetInterface/#295a635028c3
--- a/prompt.cpp Mon Oct 20 16:32:12 2014 +0000
+++ b/prompt.cpp Mon Oct 20 19:28:38 2014 +0000
@@ -330,7 +330,7 @@
ftcpport = fopen( "/qspi/tcpport.txt", "r" );
}
- if (type == 'w'){ // Create and write the default configs
+ if( type == 'w'){ // Create and write the default configs
fip = fopen("/qspi/myip.txt", "w");
fmask = fopen("/qspi/mymask.txt", "w");
fgate = fopen("/qspi/mygateway.txt", "w");
@@ -371,6 +371,48 @@
bufptr = 0;
}
}
+
+ if (type == 'e'){ // Create and write the default configs
+ fip = fopen("/qspi/myip.txt", "w");
+ fmask = fopen("/qspi/mymask.txt", "w");
+ fgate = fopen("/qspi/mygateway.txt", "w");
+ fport = fopen("/qspi/mysipport.txt", "w");
+ fsip = fopen("/qspi/serverip.txt", "w");
+ fsport = fopen("/qspi/serverport.txt", "w");
+ fext = fopen( "/qspi/myext.txt", "w" );
+ fserext = fopen( "/qspi/peerext.txt", "w" );
+ fudpport = fopen( "/qspi/udpport.txt", "w" );
+ ftcpport = fopen( "/qspi/tcpport.txt", "w" );
+
+ fprintf( fip, "%s\n\r", "" ); //myip
+ fprintf( fport, "%i\n\r", "" ); //mysipport // isso pode dar pala
+ fprintf( fext, "%i\n\r", "" ); //myext
+
+ fprintf( fsip, "%s\n\r", "" ); //asterisk ip
+ fprintf( fserext, "%i\n\r","" ); //asterisk port
+ fprintf( fsport, "%i\n\r","" ); //asterisk port
+
+ fprintf( fmask, "%s\n\r","" ); //mymask
+ fprintf( fgate, "%s\n\r", "" ); //mygateway
+
+ fprintf( fudpport, "%i\n\r","" );
+ fprintf( ftcpport, "%i\n\r","" );
+
+ files('c');
+
+ pc.printf("\n\rErased configurations set!\n\r");
+ if( from_eth ){
+ snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rErased configurations set!\n\r");
+ debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
+ if( tcp_session ){
+ tcp_client.send_all( debug_buf, strlen( debug_buf ) );
+ }else if( udp_request ){
+ udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) );
+ }
+ debug_buf[ 0 ] = 0;
+ bufptr = 0;
+ }
+ }
}
void init_fsystem(){
// init file system and check if files exist
@@ -529,7 +571,7 @@
}
if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){
miss_match = false;
- pc.printf("\n Formatando o sistema de arquivos... espere o sistema reiniciar \n\r");
+ pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r");
if( from_eth ){
snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Formatando o sistema de arquivos... espere o sistema reiniciar\n\r");
debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
@@ -540,6 +582,7 @@
udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) );
}
}
+ files('e');
files('w');
__disable_irq();
NVIC_SystemReset();
@@ -620,6 +663,7 @@
if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){
miss_match = false;
+ files('e');
files('w');
files('s');
}
@@ -715,7 +759,7 @@
}
if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ){
miss_match = false;
- pc.printf("\n\rdebug_sip");
+ pc.printf("\n\rdsip");
pc.printf("\n\rdebug_alive");
pc.printf("\n\rdebug_prompt");
pc.printf("\n\rdebug_vector");
@@ -729,14 +773,14 @@
pc.printf("\n\rdebug_file");
if( from_eth ){
- snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rdebug_sip \n\rdebug_alive \n\rdebug_prompt \n\rdebug_vector \n\rdebug_cb \n\rdebug_main \n\rdebug_cks \n\rdebug_cb_rx \n\rdebug_cb_tx* \n\rdebug_eth_rx* \n\rdebug_eth_tx* \n\rdebug_file\n\r" );
+ snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rdsip \n\rdebug_alive \n\rdebug_prompt \n\rdebug_vector \n\rdebug_cb \n\rdebug_main \n\rdebug_cks \n\rdebug_cb_rx \n\rdebug_cb_tx* \n\rdebug_eth_rx* \n\rdebug_eth_tx* \n\rdebug_file\n\r" );
debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
}
}
}
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_sip ", 10 ) ){
- if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on",2 ) ){
+ if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ",5 ) ){
+ if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ){
miss_match = false;
pc.printf( "\n\rSip Debug ON\n\r" );
if( from_eth ){
@@ -745,7 +789,7 @@
}
debug_sip = 1;
}
- if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) {
+ if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) {
miss_match = false;
pc.printf( "\n\rSip Debug OFF\n\r" );
if( from_eth ){
@@ -757,7 +801,7 @@
}
if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cks ", 10 )) {
- if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on",2 )) {
+ if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 )) {
miss_match = false;
pc.printf( "\n\rCKS Debug ON\n\r" );
if( from_eth ){
@@ -766,7 +810,7 @@
}
debug_cks = 1;
}
- if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) {
+ if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) {
miss_match = false;
pc.printf( "\n\rCKS Debug OFF\n\r" );
if( from_eth ){
@@ -778,6 +822,7 @@
}
//promptcb ramal porta comando
+ //FIXME colocar a parte eth de novo
if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) {
miss_match = false;
static uint8_t id_msg = 0x10;
@@ -791,9 +836,11 @@
split = strtok( debug_buf + 4, " " );
ext = atoi( split );
- split = strtok( NULL, " " );
- port = atoi( split );
+ //split = strtok( NULL, " " );
+ //port = atoi( split );
//split = strtok( NULL, " " );
+
+ port = convert_ext_to_port( ext );
split += strlen( split ) + 1;
promptcb_last_ext = ext;
@@ -1216,4 +1263,12 @@
pc.printf("> ");
}
return( NULL );
-}
\ No newline at end of file
+}
+
+int convert_ext_to_port( int ext ){
+ int aux = 0;
+ aux = ( ext / 1000 ) * 1000;
+ ext -= aux;
+ aux += ext % 100;
+ return( aux );
+}
--- a/prompt.h Mon Oct 20 16:32:12 2014 +0000 +++ b/prompt.h Mon Oct 20 19:28:38 2014 +0000 @@ -64,4 +64,6 @@ extern bool cb_session; extern bool cb_status; +int convert_ext_to_port( int ); + #endif \ No newline at end of file
--- a/sip.cpp Mon Oct 20 16:32:12 2014 +0000
+++ b/sip.cpp Mon Oct 20 19:28:38 2014 +0000
@@ -53,7 +53,7 @@
if( debug_sip ) debug_msg("Failed to open /qspi/serverip.txt" );
strncpy( this->server_ip, __SERVER_IP__, 20 );
}else{
- char tmp[ 16 ];
+ char tmp[ 16 ] = "\0";
int read = fread( tmp, 1, 15, fp );
if( read > 0 ){
for( int i = 0; i < read; i++ )
@@ -62,15 +62,14 @@
break;
}
strcpy( this->server_ip, tmp );
- if( debug_sip ) debug_msg("Objeto SIP fixado no server ip %s", this->server_ip );
+ if( debug_sip ) debug_msg("Objeto SIP fixado no server ip %s( read %d chars ), valid %d", this->server_ip, read, strlen( this->server_ip ) );
}else{
if( debug_sip ) debug_msg("Failed to read /qspi/serverip.txt" );
strncpy( this->server_ip, __SERVER_IP__, 20 );
}
}
fclose( fp );
- this->server_ip[ 15 ] = 0;
-
+ this->server_ip[ 15 ] = '\0';
fp = fopen( "/qspi/serverport.txt", "r");
if( fp == NULL ){
@@ -92,7 +91,7 @@
if( debug_sip ) debug_msg("Failed to open /qspi/myip.txt" );
strncpy( this->my_ip, __MY_IP__, 20 );
}else{
- char tmp[ 20 ];
+ char tmp[ 16 ] = "\0";
int read = fread( tmp, 1, 15, fp );
if( read > 0 ){
for( int i = 0; i < read; i++ )
@@ -101,7 +100,7 @@
break;
}
strcpy( this->my_ip, tmp );
- if( debug_sip ) debug_msg("Objeto SIP fixado no ip %s", this->my_ip );
+ if( debug_sip ) debug_msg("Objeto SIP fixado no ip %s( lidos %d chars ), valid %d", this->my_ip, read, strlen( this->my_ip ) );
}else{
if( debug_sip ) debug_msg("Failed to read /qspi/myip.txt" );
strncpy( this->my_ip, __MY_IP__, 20 );
@@ -109,7 +108,7 @@
}
fclose( fp );
- this->my_ip[ 15 ] = 0;
+ this->my_ip[ 15 ] = '\0';
this->my_port = my_port;
this->my_rtp_port = fill_random_rtp_port();
--- a/utils.cpp Mon Oct 20 16:32:12 2014 +0000
+++ b/utils.cpp Mon Oct 20 19:28:38 2014 +0000
@@ -46,9 +46,9 @@
int __init_eth__(){
static bool initialized = false;
- char buff_ip[ 16 ];
- char buff_msk[ 16 ];
- char buff_gtw[ 16 ];
+ char buff_ip[ 16 ] = "";
+ char buff_msk[ 16 ] = "";
+ char buff_gtw[ 16 ] = "";
wdt.kick();
pc.printf("\n\r");
FILE *fp = fopen( "/qspi/myip.txt", "r");
@@ -115,7 +115,8 @@
buff_gtw[ 15 ] = 0;
if( !initialized ){
- eth.init( buff_ip, buff_msk, buff_gtw );
+ //eth.init( buff_ip, buff_msk, buff_gtw );
+ eth.init( buff_ip, buff_msk, __MY_GTW__ );
initialized = true;
return eth.connect();
}
--- a/vz_protocol.h Mon Oct 20 16:32:12 2014 +0000 +++ b/vz_protocol.h Mon Oct 20 19:28:38 2014 +0000 @@ -46,7 +46,7 @@ //#define __MY_IP__ "192.168.2.200" //#define __MY_IP__ "192.168.2.201" -#define __MY_IP__ "192.168.120.202" +#define __MY_IP__ "192.168.120.171" #define __MY_EXT__ 820 #define __MY_PORT__ 5062 @@ -59,7 +59,8 @@ //#define __SERVER_PORT__ 5060 #define __MY_MSK__ "255.255.255.0" -#define __MY_GTW__ "192.168.2.254" +//#define __MY_GTW__ "192.168.2.254" // colinas +#define __MY_GTW__ "192.168.120.1" // colinas extern uint16_t pkg_ckserr; extern uint16_t pkg_cksok;
