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: EthernetInterface NTPClient mbed-rtos_old mbed
Fork of header_main_public by
Revision 18:01a93677e40c, committed 2014-09-19
- Comitter:
- klauss
- Date:
- Fri Sep 19 17:39:09 2014 +0000
- Parent:
- 17:67a6b557eda5
- Commit message:
- hills_01
Changed in this revision
--- a/EALib.lib Fri Sep 19 16:40:17 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/embeddedartists/code/EALib/#eb9809f2ab86
--- a/configs.cpp Fri Sep 19 16:40:17 2014 +0000
+++ b/configs.cpp Fri Sep 19 17:39:09 2014 +0000
@@ -8,17 +8,11 @@
// Pins/Modules Config
//*****************************************************************************
-QSPIFileSystem qspifs("qspi"); // file system
-
-Watchdog wdt;
-
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
-DigitalOut hack_led( p24 );
-
DigitalOut DataReady(p11); //IO 27
DigitalOut data0(p30); //LSB
@@ -47,13 +41,13 @@
void start_cpld( void ) { //CPLD Start
- static uint16_t reset = 0;//10000;
+ static uint16_t reset = 10000;
ENABLE_F_REG = 1;
ENABLE_F_TX = 1;
ENABLE_F_RX = 1;
DataReady = 0;
RST = 1;
- while( reset++ < 10000 ){}
+ while(reset--){}
RST = 0;
}
--- a/configs.h Fri Sep 19 16:40:17 2014 +0000 +++ b/configs.h Fri Sep 19 17:39:09 2014 +0000 @@ -1,20 +1,13 @@ #ifndef _CONFIGS_H #define _CONFIGS_H #include "mbed.h" -#include "wdt.h" -#include "QSPIFileSystem.h" #define DATA_SIZE 300 -extern Watchdog wdt; - -extern QSPIFileSystem qspifs; //FileSystem - extern DigitalOut led1; extern DigitalOut led2; extern DigitalOut led3; extern DigitalOut led4; -extern DigitalOut hack_led; extern DigitalOut DataReady; //IO 27
--- a/main.cpp Fri Sep 19 16:40:17 2014 +0000
+++ b/main.cpp Fri Sep 19 17:39:09 2014 +0000
@@ -3,7 +3,7 @@
#include "configs.h"
#include "UART3Interrupt.h"
#include "parallelcpld.h"
-#include "prompt.h"
+
#include "debug.h"
#include "utils.h"
@@ -27,8 +27,6 @@
int main(){
start_cpld();
config_lpc();
- init_fsystem();
- wdt.Configure( 40.0 );
/* referencia e inicio da conexao com a ethernet */
EthernetInterface eth;
@@ -36,8 +34,7 @@
int eth_status = __init_eth__( ð );
if( eth_status ){
- debug_msg("Sem conexao eth");
- //NVIC_SystemReset();
+ debug_msg("Sem conexao eth");
}
/* debugs */
@@ -104,9 +101,7 @@
}
reset_leds();
debug_msg( " Ready " );
- while( true ){
- prompt_process();
- wdt.kick();
+ while( true ){
if( status != __WAITING__ ){
__read_cb_buffer__( buffer, buffer_from_cb_ptr );
status = __WAITING__;
@@ -114,7 +109,7 @@
data = __parse_cb_buffer__( &ext, &port, &type, buffer );
if( data != NULL ){
- debug_msg("Package from :: %d -- Type :: %d", ext, type );
+ debug_msg("Procurando pelo CBx :: %d -- Type :: %d", ext, type );
if( type != __AUDIO__ ){
Call_Box * cb = __find_CB__( v_cb, ext );
if( cb != NULL ){
@@ -138,17 +133,14 @@
}else type = __DO_NOTHING__;
}
//----------------------
- if( t.read() > 5 ){
- if( debug_alive ){
- for( register uint8_t i = 0; i < v_cb->size(); i++ ){
- Call_Box * cb = ( Call_Box * )v_cb->get_element( i );
- debug_msg(" Type :: %d -- Ext :: %d -- TimeSlice :: %d -- remain_timeslices :: %d :: v_call->size() :: %d :: Status :: %d :: SIP Status %d", type , cb->get_ext(), cb->get_timeslice(), ts->remain_timeslices(), v_call->size(), cb->status, cb->sip->status );
- }
- if( v_cb->size() != 0 ) debug_msg("");
+ if( t.read() > 5 ){
+ for( register uint8_t i = 0; i < v_cb->size(); i++ ){
+ Call_Box * cb = ( Call_Box * )v_cb->get_element( i );
+ debug_msg(" Type :: %d -- Ext :: %d -- TimeSlice :: %d -- remain_timeslices :: %d :: v_call->size() :: %d :: Status :: %d :: SIP Status %d", type , cb->get_ext(), cb->get_timeslice(), ts->remain_timeslices(), v_call->size(), cb->status, cb->sip->status );
}
+ debug_msg("");
t.reset();
led3 = !led3;
- hack_led = !hack_led;
}
//----------------------
switch( type ){
@@ -158,6 +150,7 @@
case __CB_BYE__ : {
Call_Box * cb = __find_CB__( v_cb, ext );
if( cb != NULL ){
+ debug_msg("Nao encontrado CBx :: %d -- Type :: %d", ext, type );
data[ 0 ] |= BIT7;
cb->set_msg_id( data[ 0 ] );
debug_msg( " Request bye from CBx " );
@@ -184,6 +177,7 @@
debug_msg("ok -- recebido o invite pelo menos");
Call_Box * cb = __find_CB__( v_cb, ext );
if( cb == NULL ){
+ debug_msg("Nao encontrado CBx :: %d -- Type :: %d", ext, type );
cb = new Call_Box( ext, port );
v_cb->add( cb );
set_status( cb->status, cb_idle );
@@ -202,7 +196,7 @@
break;
}
set_status( cb->status, cb_trying );
- debug_msg("Invite request from CBx -- %d :: Status %d", ext, cb->status );
+ debug_msg(" Ok temos um cbx encontrado com status :: %d", cb->status );
switch( cb->status ){
case cb_on_call : {
// a priori, nao fazer nada
@@ -245,7 +239,7 @@
debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] );
__send_to_cb__( __build_cb_package__( ext, port, __INVITE__,
( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) );
- debug_msg( "-- Trying -- aceitando pedido de invite --" );
+ debug_msg( "-- Trying -- aceitando pedido de invite -- %s ", write_buffer );
//debug_pkg( 300, write_buffer );
}else{
set_status( cb->status,cb_idle);
@@ -255,21 +249,13 @@
debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] );
__send_to_cb__( __build_cb_package__( ext, port, __CB_BYE__,
( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) );
- debug_msg( "-- Trying -- Negando pedido de invite --" );
+ debug_msg( "-- Trying -- Negando pedido de invite -- %s ", write_buffer );
set_status( cb->sip->status, sip_idle);
}
}
}break;
case cb_busy : {
- set_status( cb->status,cb_idle);
- ts->return_timeslice( cb->get_timeslice() );
- cb->set_timeslice( 0x00 );
- data[ __TIMESLICE_PLACE__ ] = 0x00;
- debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] );
- __send_to_cb__( __build_cb_package__( ext, port, __CB_BYE__,
- ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) );
- debug_msg( "-- Trying -- Negando pedido de invite << Busy Here >> --" );
- set_status( cb->sip->status, sip_idle );
+ // tratar sip
}break;
}
}break;
@@ -282,6 +268,7 @@
cb->reset_elapsed_time();
debug_msg(" reset_elapsed_time CBx -- %d", ext );
}else{
+ debug_msg("Nao encontrado CBx :: %d -- Type :: %d", ext, type );
cb = new Call_Box( ext, port );
v_cb->add( cb );
debug_msg(" Criado CBx -- %d", ext );
@@ -310,6 +297,8 @@
call->send_message( pkg );
cb = __find_CB__( v_cb, ext );
if( cb != NULL ) cb->reset_elapsed_time();
+ }else{
+ debug_msg("Nao encontrado CBx :: %d -- Type :: %d", ext, type );
}
}break;
}// fim switch
@@ -324,7 +313,7 @@
if( cb != NULL ){
cb_port = cb->get_port();
- }
+ }else debug_msg("Nao encontrado CBx :: %d -- Type :: %d", ext, type );
uint8_t * pkg2cb = __build_cb_package__( call->get_cb_ext(), cb_port, __AUDIO__,
tmp, __AUDIO__, length, write_buffer );
@@ -357,7 +346,7 @@
cb->reset_sip();
set_status( cb->sip->status, sip_idle );
}
- }
+ }else debug_msg("Nao encontrado CBx :: %d -- Type :: %d", ext, type );
}
call_manager( v_call, v_cb, buffer, write_buffer, ts );
--- a/mbed-rtos.lib Fri Sep 19 16:40:17 2014 +0000 +++ b/mbed-rtos.lib Fri Sep 19 17:39:09 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#143f8e17efc5 +http://mbed.org/teams/VZTECH/code/mbed-rtos/#bd07334df5b1
--- a/prompt.cpp Fri Sep 19 16:40:17 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,346 +0,0 @@
-#include "mbed.h"
-#include "stdint.h"
-#include "configs.h"
-#include "vz_protocol.h"
-#include "parallelcpld.h"
-//#include "debug.h"
-
-uint8_t debug_alive = 1;
-
-#define PVERSION 1 // Sempre atualizar a versao do prompt
-
-#define DEBUGBUFSIZE 40
-char debug_buf[DEBUGBUFSIZE];
-FILE *fip,*fmask,*fgate,*fport,*fsip,*fsport;
-uint8_t dog = 1;
-uint8_t debug_prompt = 0;
-uint8_t bufptr = 0;
-
-
-uint8_t xmemmatch(const uint8_t * s1, const uint8_t * s2, uint16_t size) { // presente da lib.h pode retirar da versao final
- while (size--) {
- if (*s1++ != *s2++) return 0; /* does not match */
- }
- return 1; /* matches */
-}
-
-uint8_t xstrmatch(const uint8_t * s1, const uint8_t * s2) { // presente na lib.h pode retirar da versao final
- while (*s1) {
- if (*s1++ != *s2++) return 0; /* does not match */
- }
- if ( *s2 == 0 )
- return 1; /* matches */
- else
- return 0; /* does not match */
-}
-
-void xmemcpy(uint8_t * dest, const uint8_t * src, uint16_t size) { // presente na lib.h pode retirar da versao final
- while (size--) *dest++ = *src++;
-}
-
-
-void cat(const char* fname) // Print the content of a given file
-{
- char buff[513];
- int num;
-
- FILE *fp = fopen(fname, "r");
- if (fp == NULL) {
- pc.printf("Failed to open %s\n", fname);
- return;
- }
-
- while ((num = fread(buff, 1, 512, fp)) > 0)
- {
- buff[num] = '\0';
- pc.printf(buff);
-
- }
- fclose(fp);
-}
-
-
-void files (const char type) { // operantion with the system config files
-
- if (type == 's' ){ // show files
- pc.printf("\n\r");
- pc.printf("1)IP, 2)MASK, 3)GATEWAY, 4)SIP PORT, 5)SERVER IP, 6)SERVER SIP PORT\n\r");
- cat("/qspi/myip.txt");
- cat("/qspi/mymask.txt");
- cat("/qspi/mygate.txt");
- cat("/qspi/mysipport.txt");
- cat("/qspi/serverip.txt");
- cat("/qspi/serverport.txt");
- }
-
-
- if (type == 'c' ){ // close all files
- fclose(fip);
- fclose(fmask);
- fclose(fgate);
- fclose(fport);
- fclose(fsip);
- fclose(fsport);
-
- }
-
- if (type == 'i' ){ // Check if files exist, if not create the files
- fip = fopen("/qspi/myip.txt", "r");
- if (fip == NULL){
- fip = fopen("/qspi/myip.txt", "w");
- fprintf(fip, "192.168.120.169\n\r"); //myip
- }
- fmask = fopen("/qspi/mymask.txt", "r");
- if (fmask == NULL){
- fmask = fopen("/qspi/mymask.txt", "w");
- fprintf(fmask, "255.255.255.0\n\r"); //mymask
- }
- fgate = fopen("/qspi/mygateway.txt", "r");
- if (fgate == NULL){
- fgate = fopen("/qspi/mygate.txt", "w");
- fprintf(fgate, "192.168.2.254\n\r"); //mygateway
- }
- fport = fopen("/qspi/mysipport.txt", "r");
- if (fport == NULL){
- fport = fopen("/qspi/mysipport.txt", "w");
- fprintf(fport, "5075\n\r"); //mysipport
- }
- fsip = fopen("/qspi/serverip.txt", "r");
- if (fsip == NULL){
- fsip = fopen("/qspi/serverip.txt", "w");
- fprintf(fsip, "192.168.30.25\n\r"); //asterisk ip
- }
- fsport = fopen("/qspi/serverport.txt", "r");
- if (fsport == NULL){
- fsport = fopen("/qspi/serverport.txt", "w");
- fprintf(fsport, "5060\n\r"); //asterisk port
- pc.printf("\n\r Default configurations set! \n\r");
- }
-
- }
-
- if (type == 'r' ){ // Just open for read
- fip = fopen("/qspi/myip.txt", "r");
- fmask = fopen("/qspi/mymask.txt", "r");
- fgate = fopen("/qspi/mygateway.txt", "r");
- fport = fopen("/qspi/mysipport.txt", "r");
- fsip = fopen("/qspi/serverip.txt", "r");
- fsport = fopen("/qspi/serverport.txt", "r");
- }
-
- 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");
- fport = fopen("/qspi/mysipport.txt", "w");
- fsip = fopen("/qspi/serverip.txt", "w");
- fsport = fopen("/qspi/serverport.txt", "w");
-
- fprintf(fip, "192.168.120.169\n\r"); //myip
- fprintf(fmask, "255.255.255.0\n\r"); //mymask
- fprintf(fgate, "192.168.2.254\n\r"); //mygateway
- fprintf(fport, "5075\n\r"); //mysipport
- fprintf(fsip, "192.168.30.25\n\r"); //asterisk ip
- fprintf(fsport, "5060\n\r"); //asterisk port
-
- files('c');
-
- pc.printf("\n\r Default configurations set! \n\r");
-
- }
-
-}
-
-void init_fsystem(){ // init file system and check if files exist
- if (!qspifs.isformatted()) {
- qspifs.format();
- pc.printf("File system configured!!\n\r");
- }
-
- files('i'); // check if the files are created
- files('c');
- pc.printf("*******System Ready*******\n\r");
-}
-
-
-void prompt_process(){ // main prompt process
- volatile char b = 0;
- static uint8_t bufret = 0;
-
- if (pc.readable()){
-
- b = pc.getc();
-
- if (b == 0x0D){
- bufret = 1;
- }
- else{
- pc.putc(b);
- debug_buf[bufptr] = b;
- bufptr++;
- }
- }
-
- if (bufret == 1){ // Prompt commands here
-
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "sconfig" )) {
- pc.printf("\n\r");
- files('s');
- }
-
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" )) {
- pc.printf("\n Formatando o sistema de arquivos... espere o sistema reiniciar \n\r");
- qspifs.format();
- NVIC_SystemReset();
- }
-
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ",6 )) {
- fip = fopen("/qspi/myip.txt", "w");
- fprintf(fip,"%s\n\r",(debug_buf+6));
- fclose(fip);
- pc.printf("\n\r");
- files('s');
- }
-
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 )) {
- fmask = fopen("/qspi/mymask.txt", "w");
- fprintf(fmask,"%s\n\r",(debug_buf+8));
- fclose(fmask);
- pc.printf("\n\r");
- files('s');
- }
-
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 )) {
- fgate = fopen("/qspi/mygate.txt", "w");
- fprintf(fgate,"%s\n\r",(debug_buf+11));
- fclose(fgate);
- pc.printf("\n\r");
- files('s');
- }
-
-
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 )) {
- fport = fopen("/qspi/mysipport.txt", "w");
- fprintf(fport,"%s\n\r",(debug_buf+9));
- fclose(fport);
- pc.printf("\n\r");
- files('s');
- }
-
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 )) {
- fsip = fopen("/qspi/serverip.txt", "w");
- fprintf(fsip,"%s\n\r",(debug_buf+9));
- fclose(fsip);
- pc.printf("\n\r");
- files('s');
- }
-
- if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ",7 )) {
- fsport = fopen("/qspi/serverport.txt", "w");
- fprintf(fsport,"%s\n\r",(debug_buf+7));
- fclose(fsport);
- pc.printf("\n\r");
- files('s');
- }
-
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" )) {
- files('w');
- files('s');
-
- }
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" )) {
- pc.printf("\n\r reset!!! \n\r");
- pc.putc(0x01);
- NVIC_SystemReset();
- }
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" )) {
- pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r");
- dog = 0;
- }
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "debug off" )) {
- pc.printf("Disable debug");
- debug_alive = 0;
- }
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "debug on" )) {
- pc.printf("Disable debug");
- debug_alive = 1;
- }
-
-
- if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) {
- pc.printf("\n\r****************************PROMPT HELP******************\n\r");
- pc.printf("sconfig - mostra o arquivo de configuracao do sistema\n\r");
- pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r");
- pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r");
- pc.printf("format - formata o sistema de arquivos\n\r");
- pc.printf("reset - resta o sistema\n\r");
- pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r");
- pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r");
- pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r");
- pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r");
- pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r");
- pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r");
- pc.printf("\n\rPROMPT VERSION: V%d\n\r",PVERSION);
- }
- /*
- if ( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )) {
- if ( debug_buf[16] != 0 && debug_buf[11] != 0x20 )
- pc.printf("\n\r Error: formato errado! ramal=xxxx porta=xxxx \n\r");
- else {
- uint8_t data[300];
- uint16_t cks=0;
-
- //data[0] = (uint8_t)( (debug_buf[7]&0xf0)<<4 + (debug_buf[8]&0x0f) ) ;
- //data[1] = (uint8_t)( (debug_buf[9]&0xf0)<<4 + (debug_buf[10]&0x0f) ) ;
- //data[2] = (uint8_t)( (debug_buf[12]&0xf0)<<4 + (debug_buf[13]&0x0f) ) ;
- /data[3] = (uint8_t)( (debug_buf[14]&0xf0)<<4 + (debug_buf[15]&0x0f) ) ;
-
- data[0] = (uint8_t)( debug_buf[ 7 ] & 0xFF00 >> 8 );
- data[1] = (uint8_t)( debug_buf[ 9 ] & 0x00FF );
- data[2] = (uint8_t)( debug_buf[ 12 ] & 0xFF00 >> 8 );
- data[3] = (uint8_t)( debug_buf[ 14 ] & 0x00FF );
-
- data[6] = 0x04;
- for (int i = 7; i < 300; i++) data[i] = 0x00;
- cks = __checksum__(data,300);
- data[4] = cks>>8;
- data[5] = cks&0xff;
-
- pc.printf("\n\r");
- for( int i = 0; i < 300; i++ )
- pc.printf("%x ", data[ i ] );
- pc.printf("\n\r");
-
- xmemcpy(TXBuffer,data,300);
-
- pc.printf("\n\r");
- for( int i = 0; i < 300; i++ )
- pc.printf("%x ", data[ i ] );
- pc.printf("\n\r");
-
- send2callboxes();
-
- pc.printf("\n\r calling callbox %s \n\r",debug_buf+7);
- }
-
- }
- */
- }
-
- if (b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ){
- bufptr = 0;
- for (uint8_t i =0; i < DEBUGBUFSIZE; i++){
- debug_buf[i] = 0;
- }
- bufret = 0;
- pc.putc(0x0A);
- pc.putc(0x0D);
- }
-}
\ No newline at end of file
--- a/prompt.h Fri Sep 19 16:40:17 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#ifndef _PROMPT_H -#define _PROMPT_H - -extern uint8_t debug_alive; -extern uint8_t debug_prompt; -extern uint8_t dog; - -void prompt_process(); -void init_fsystem(); - - -#endif \ No newline at end of file
--- a/sip.cpp Fri Sep 19 16:40:17 2014 +0000
+++ b/sip.cpp Fri Sep 19 17:39:09 2014 +0000
@@ -183,15 +183,6 @@
}
}
if( ( status == sip_trying ) || ( status == sip_ringing ) ){
- if( !( strncasecmp( buffer + 12, "Busy Here", strlen("Busy Here") ) ) ){
- debug_msg("Busy Here");
- send_bye();
- delete( call );
- set_status( status, sip_busy );
- return( NULL );
- }
- }
- if( ( status == sip_trying ) || ( status == sip_ringing ) ){
if( !( strncasecmp( buffer + 12, "Session Progress", strlen("Session Progress") ) ) ){
debug_msg( "Trocando dados de audio -- musica de espera com o CBx" );
char *ref = strstr( buffer, "audio" );
@@ -223,7 +214,6 @@
sock.init();
sock.set_blocking( false, 1 );
debug_msg("Reconnect");
- wdt.kick();
reconnect.reset();
//sock.sendTo( sip_server, buffer, sizeof( buffer ) );
led4 = !led4;
--- a/sip.h Fri Sep 19 16:40:17 2014 +0000 +++ b/sip.h Fri Sep 19 17:39:09 2014 +0000 @@ -24,17 +24,21 @@ */ #define __MY_PORT__ 5062 #define __MY_EXT__ 820 +//#define __PEER_EXT__ 801 #define __PEER_EXT__ 913 +//#define __PEER_EXT__ 803 -//#define colinas_config -#ifdef colinas_config + +//#ifdef debug_colinas #define __SEVER_IP__ "192.168.30.25" #define __SERVER_PORT__ 5060 -#endif -#ifndef colinas_config -#define __SEVER_IP__ "192.168.120.120" -#define __SERVER_PORT__ 5075 -#endif +//#endif +//#ifndef debug_colinas +//#define __SEVER_IP__ "192.168.120.120" +//#define __SEVER_IP__ "192.168.30.25" +//#define __SERVER_PORT__ 5075 +//#define __SERVER_PORT__ 5060 +//#endif #define sip_idle 0 #define sip_waiting_trying 1 << 1
--- a/utils.cpp Fri Sep 19 16:40:17 2014 +0000
+++ b/utils.cpp Fri Sep 19 17:39:09 2014 +0000
@@ -43,8 +43,7 @@
int __init_eth__( EthernetInterface * eth ){
//eth->init( __MY_IP__, "255.255.255.0", "192.168.120.1" );
- //eth->init( "192.168.2.200", "255.255.255.0", "192.168.2.254" );
- eth->init( __MY_IP__, __MY_MK__, __MY_GW__ );
+ eth->init( "192.168.2.200", "255.255.255.0", "192.168.2.254" );
/*
#ifdef debug_colinas
--- a/utils.h Fri Sep 19 16:40:17 2014 +0000 +++ b/utils.h Fri Sep 19 17:39:09 2014 +0000 @@ -15,7 +15,6 @@ #include "NTPClient.h" #include "parallelcpld.h" #include "test.h" -#include "configs.h" using namespace std;
--- a/vz_protocol.cpp Fri Sep 19 16:40:17 2014 +0000
+++ b/vz_protocol.cpp Fri Sep 19 17:39:09 2014 +0000
@@ -22,11 +22,24 @@
uint16_t cc = ( uint16_t )cb_buffer[ 4 ] << 8 | cb_buffer[ 5 ];
- uint16_t calc_cc = __checksum__( cb_buffer, __CB_BUFFER_SIZE__ );
+ /*
+ UDPSocket debug;
+ Endpoint debug_server;
+ char debug_msg[ 1024 ];
+
+ debug_server.set_address( "192.168.120.180", 9897 );
+ debug.bind( 8182 );
+ debug.init();
- if( cc != calc_cc ){
- debug_msg("wrong check sum -- calc :: %d ( %d ) -- diff %d", calc_cc, cc, ( cc > calc_cc ) ? cc - calc_cc : calc_cc - cc );
- return( NULL );
+ //if( cc != __checksum__( cb_buffer + __CHECKSUM_OFFSET__,
+ // __CB_BUFFER_SIZE__ - __CHECKSUM_OFFSET__ ) ){
+
+ sprintf( debug_msg, " -- cc :: %x :: __checksum %x -- bit[4] %x :: bit[5] %x", cc, __checksum__( cb_buffer, __CB_BUFFER_SIZE__ ), cb_buffer[ 4 ], cb_buffer[ 5 ] );
+ debug.sendTo( debug_server, debug_msg, strlen( debug_msg ) );
+ debug.sendTo( debug_server, debug_msg, strlen( debug_msg ) );
+ */
+ if( cc != __checksum__( cb_buffer, __CB_BUFFER_SIZE__ ) ){
+ return( NULL );
}else{
e_msb = cb_buffer[ 0 ];
e_lsb = cb_buffer[ 1 ];
@@ -42,7 +55,7 @@
}
}
uint8_t * __build_cb_package__( int ext, int port, uint8_t type, char * cb_buffer, uint8_t seq_num, int length, uint8_t * pkg ){
- //debug_msg("");
+ debug_msg("");
pkg[ 0 ] = ( uint8_t )( ( ext & 0xFF00 ) >> 8 );
pkg[ 1 ] = ( uint8_t )( ext & 0x00FF );
pkg[ 2 ] = ( uint8_t )( ( port & 0xFF00 ) >> 8 );
@@ -84,7 +97,7 @@
pkg[ 4 ] =( uint8_t )( ( cc & 0xFF00 ) >> 8) ;
pkg[ 5 ] =( uint8_t )( cc & 0x00FF );
- //debug_msg("");
+ debug_msg("");
return pkg;
}
--- a/vz_protocol.h Fri Sep 19 16:40:17 2014 +0000 +++ b/vz_protocol.h Fri Sep 19 17:39:09 2014 +0000 @@ -36,18 +36,8 @@ #define __DO_NOTHING__ 0x99 -//#define colinas -#ifdef colinas +//#define __MY_IP__ "192.168.120.169" #define __MY_IP__ "192.168.2.200" -#define __MY_GW__ "192.168.2.254" -#endif -#ifndef colinas -#define __MY_IP__ "192.168.120.169" -#define __MY_GW__ "192.168.120.1" -#endif - -#define __MY_MK__ "255.255.255.0" - uint16_t __checksum__( uint8_t * buffer, size_t length );
--- a/wdt.cpp Fri Sep 19 16:40:17 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-#include "mbed.h"
-#include "wdt.h"
-
- /// Watchdog gets instantiated at the module level
-Watchdog::Watchdog() {
- wdreset = (LPC_WDT->MOD >> 2) & 1; // capture the cause of the previous reset
-}
-
-/// Load timeout value in watchdog timer and enable
-void Watchdog::Configure(float s) {
- //LPC_WDT->CLKSEL = 0x1; // Set CLK src to PCLK
- uint32_t clk = 500000 / 4; // WD has a fixed /4 prescaler, and a 500khz oscillator
- LPC_WDT->TC = (uint32_t)(s * (float)clk);
- LPC_WDT->MOD = 0x3; // Enabled and Reset
- kick();
-}
-
-/// "Service", "kick" or "feed" the dog - reset the watchdog timer
-/// by writing this required bit pattern
-void Watchdog::kick() {
- LPC_WDT->FEED = 0xAA;
- LPC_WDT->FEED = 0x55;
-}
-
\ No newline at end of file
--- a/wdt.h Fri Sep 19 16:40:17 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#ifndef _WDT_H
-#define _WDT_H
-#include "mbed.h"
-
-class Watchdog {
-public:
- /// Create a Watchdog object
- ///
- /// example:
- /// @code
- /// Watchdog wd; // placed before main
- /// @endcode
- Watchdog();
-
- /// Configure the timeout for the Watchdog
- ///
- /// This configures the Watchdog service and starts it. It must
- /// be serviced before the timeout, or the system will be restarted.
- ///
- /// example:
- /// @code
- /// ...
- /// wd.Configure(1.4); // configure for a 1.4 second timeout
- /// ...
- /// @endcode
- ///
- /// @param timeout in seconds, as a floating point number
- /// @returns none
- ///
- void Configure(float timeout);
-
- /// Service the Watchdog so it does not cause a system reset
- ///
- /// example:
- /// @code
- /// wd.Service();
- /// @endcode
- /// @returns none
- void kick();
-
- /// WatchdogCausedReset identifies if the cause of the system
- /// reset was the Watchdog
- ///
- /// example:
- /// @code
- /// if (wd.WatchdogCausedReset())) {
- /// @endcode
- ///
- /// @returns true if the Watchdog was the cause of the reset
- bool WatchdogCausedReset();
-private:
- bool wdreset;
-};
-
-
-
-
-#endif
