6 |
|
|
7 |
#include "lcd.h" |
#include "lcd.h" |
8 |
#include "Delay.h" |
#include "Delay.h" |
|
// Delay.h is included inside lcd.c |
|
9 |
|
|
10 |
#define BUFFER 128 |
#define BUFFER 128 |
11 |
#define PWRFAIL RB1 |
#define PWRFAIL RB1 |
151 |
RCSTA = 0x90; // 0x90 enables SPEN and CREN in the RCSTA register |
RCSTA = 0x90; // 0x90 enables SPEN and CREN in the RCSTA register |
152 |
} |
} |
153 |
|
|
154 |
void sms_init(void) |
void modem_init(void) |
155 |
{ |
{ |
156 |
int i; |
int i; |
157 |
char buf[2]; |
char buf[2]; |
218 |
|
|
219 |
void on_initial_recieve(void) |
void on_initial_recieve(void) |
220 |
{ |
{ |
221 |
char imei[16]; |
// can't se what the outcommented lines in here sould do, that make any sence. |
222 |
char* ptr; |
// char imei[16]; |
223 |
char i; |
// char* ptr; |
224 |
char buf[2]; |
// char i; |
225 |
|
// char buf[2]; |
226 |
|
|
227 |
if (strstr(global_serial_recieve_buffer,"+WIND: 11") != 0) |
if (strstr(global_serial_recieve_buffer,"+WIND: 11") != 0) |
228 |
{ |
{ |
229 |
global_modem_init = 1; |
global_modem_init = 1; |
230 |
|
|
231 |
ptr = strstr(global_serial_recieve_buffer,"cgsn"); |
// ptr = strstr(global_serial_recieve_buffer,"cgsn"); |
232 |
ptr +=4; |
// ptr +=4; |
233 |
strncpy(imei, ptr,15); |
// strncpy(imei, ptr,15); |
234 |
imei[15] = 0; |
// imei[15] = 0; |
235 |
|
|
236 |
reset_recieve_buffer(); |
reset_recieve_buffer(); |
237 |
} |
} |
305 |
TMR1L = 0xFF; |
TMR1L = 0xFF; |
306 |
global_time_counter++; |
global_time_counter++; |
307 |
global_emergency_counter++; |
global_emergency_counter++; |
308 |
RA1 = !RA1; |
// RA1 = !RA1; |
309 |
} |
} |
310 |
////////// ORDENARY FUNKTIONS ////////// |
////////// ORDENARY FUNKTIONS ////////// |
311 |
void update_lcd(void) |
void update_lcd(void) |
405 |
if (strstr(global_message_buffer1,"CMTI") != 0) // here we handles a incomming SMS |
if (strstr(global_message_buffer1,"CMTI") != 0) // here we handles a incomming SMS |
406 |
{ |
{ |
407 |
ptr = strstr(global_message_buffer1,","); // finds the point just before the nr. of the SMS. |
ptr = strstr(global_message_buffer1,","); // finds the point just before the nr. of the SMS. |
408 |
strcat(tmp,ptr+1); // puts that number in tmp |
strcat(tmp,ptr+1); // puts that number in tmp |
409 |
global_sms_recieve_number[0] = 0; // wanna be sure that we write the new number from global_sms_recieve_number[0] |
global_sms_recieve_number[0] = 0; // wanna be sure that we write the new number from global_sms_recieve_number[0] |
410 |
strcat(global_sms_recieve_number, tmp); // puts the sms number into the global variable. |
strcat(global_sms_recieve_number, tmp); // puts the sms number into the global variable. |
411 |
sms_recieved(); |
sms_recieved(); |
412 |
} |
} |
413 |
reset_recieve_buffer(); |
reset_recieve_buffer(); |
455 |
|
|
456 |
global_time_interval = atoi(buf); |
global_time_interval = atoi(buf); |
457 |
global_time_interval *= 60; |
global_time_interval *= 60; |
458 |
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. |
459 |
send_sms("conf ok"); |
send_sms("conf ok"); |
460 |
} |
} |
461 |
|
|
476 |
|
|
477 |
// Running init for various components. |
// Running init for various components. |
478 |
pic18_io_init(); |
pic18_io_init(); |
479 |
RA5 = 1; // Indicates that the board is running inits. |
RA5 = 1; // Indicates that the board is running inits. |
480 |
|
|
481 |
rs232_init(); |
rs232_init(); |
482 |
ad_init(); |
ad_init(); |
485 |
lcd_home(); |
lcd_home(); |
486 |
interrupt_init(); |
interrupt_init(); |
487 |
timer_init(); |
timer_init(); |
488 |
sms_init(); |
modem_init(); |
489 |
eeprom_reader(); |
eeprom_reader(); |
490 |
/////////////// |
/////////////// |
491 |
// Main loop // |
// Main loop // |