--- trunk/Embedded/main.c 2007/12/06 14:19:51 178 +++ trunk/Embedded/main.c 2007/12/09 21:47:39 207 @@ -6,7 +6,6 @@ #include "lcd.h" #include "Delay.h" -// Delay.h is included inside lcd.c #define BUFFER 128 #define PWRFAIL RB1 @@ -17,8 +16,8 @@ unsigned char global_Pot_Hi, global_Pot_Lo; unsigned char global_serial_send[BUFFER], global_serial_recieve_buffer[BUFFER]; -bit global_recieve_done = 0, global_interval_changed = 0; -unsigned int global_serial_byte_counter = 0, global_sms_counter = 1, global_time_counter = 0, global_time_counter_image = 0; +bit global_recieve_done = 0; //, global_interval_changed = 0; +unsigned int global_serial_byte_counter = 0, global_sms_counter = 1, global_time_counter = 0; //, global_time_counter_image = 0; unsigned int global_emergency_counter = 600, global_time_interval = 3600; unsigned char global_temp = 0; @@ -46,7 +45,7 @@ void serial_recieved(void); void serial_send(void); void update_lcd(void); -void convertTemp(void); +void convert_temp(void); void timer1_interrupt(void); void on_recieve(void); void on_initial_recieve(void); @@ -152,7 +151,7 @@ RCSTA = 0x90; // 0x90 enables SPEN and CREN in the RCSTA register } -void sms_init(void) +void modem_init(void) { int i; char buf[2]; @@ -219,19 +218,20 @@ void on_initial_recieve(void) { - char imei[16]; - char* ptr; - char i; - char buf[2]; +// can't se what the outcommented lines in here sould do, that make any sence. +// char imei[16]; +// char* ptr; +// char i; +// char buf[2]; if (strstr(global_serial_recieve_buffer,"+WIND: 11") != 0) { global_modem_init = 1; - ptr = strstr(global_serial_recieve_buffer,"cgsn"); - ptr +=4; - strncpy(imei, ptr,15); - imei[15] = 0; +// ptr = strstr(global_serial_recieve_buffer,"cgsn"); +// ptr +=4; +// strncpy(imei, ptr,15); +// imei[15] = 0; reset_recieve_buffer(); } @@ -305,7 +305,7 @@ TMR1L = 0xFF; global_time_counter++; global_emergency_counter++; - RA1 = !RA1; +// RA1 = !RA1; } ////////// ORDENARY FUNKTIONS ////////// void update_lcd(void) @@ -347,7 +347,7 @@ } } -void convert_temp() +void convert_temp(void) { short adVal; adVal = (global_Pot_Hi << 8) | global_Pot_Lo; @@ -405,9 +405,9 @@ if (strstr(global_message_buffer1,"CMTI") != 0) // here we handles a incomming SMS { ptr = strstr(global_message_buffer1,","); // finds the point just before the nr. of the SMS. - strcat(tmp,ptr+1); // puts that number in tmp - global_sms_recieve_number[0] = 0; // wanna be sure that we write the new number from global_sms_recieve_number[0] - strcat(global_sms_recieve_number, tmp); // puts the sms number into the global variable. + strcat(tmp,ptr+1); // puts that number in tmp + global_sms_recieve_number[0] = 0; // wanna be sure that we write the new number from global_sms_recieve_number[0] + strcat(global_sms_recieve_number, tmp); // puts the sms number into the global variable. sms_recieved(); } reset_recieve_buffer(); @@ -455,7 +455,7 @@ global_time_interval = atoi(buf); global_time_interval *= 60; - eeprom_writer(); // writes the new cell nr. and time interval to the eeprom. + eeprom_writer(); // writes the new cell nr. and time interval to the eeprom. send_sms("conf ok"); } @@ -476,7 +476,7 @@ // Running init for various components. pic18_io_init(); - RA5 = 1; // Indicates that the board is running inits. + RA5 = 1; // Indicates that the board is running inits. rs232_init(); ad_init(); @@ -485,7 +485,7 @@ lcd_home(); interrupt_init(); timer_init(); - sms_init(); + modem_init(); eeprom_reader(); /////////////// // Main loop // @@ -514,12 +514,13 @@ if( global_emergency_counter > 7200 ) global_emergency_counter = 600; +// the outcommented lines are useless, because eeprom_writer() is called from sms_recieved() when the conf sms has been decoded. // Checks if there has been recieved a config sms. - if(global_interval_changed ) - { - eeprom_writer(); - global_interval_changed = 0; - } +// if(global_interval_changed ) +// { +// eeprom_writer(); +// global_interval_changed = 0; +// } // Checking if A/D convertion is done, and save the data in global_Pot_?? if(GODONE==0) {