/[H9]/trunk/Embedded/main.c
ViewVC logotype

Diff of /trunk/Embedded/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 172 by hedin, Wed Dec 5 16:11:12 2007 UTC revision 173 by hedin, Thu Dec 6 12:30:39 2007 UTC
# Line 53  void on_recieve(void); Line 53  void on_recieve(void);
53  void on_initial_recieve(void);  void on_initial_recieve(void);
54  void sms_recieved(void);  void sms_recieved(void);
55  void send_sms(const unsigned char* payload);  void send_sms(const unsigned char* payload);
56    void eeprom_writer(void);
57    
58  void reset_recieve_buffer(void)  void reset_recieve_buffer(void)
59  {  {
# Line 99  void ad_init(void) // Nicked from H7 Line 99  void ad_init(void) // Nicked from H7
99          PCFG2=1;          PCFG2=1;
100          PCFG3=1;          PCFG3=1;
101                    
102            //Reset the A/D result registers
103            ADRESH = 0;
104            ADRESL = 0;
105            
106          //Result is right justified          //Result is right justified
107          ADFM=1;          ADFM=1;
108                    
# Line 148  void sms_init(void) Line 152  void sms_init(void)
152  {  {
153          int i;          int i;
154          char buf[2];          char buf[2];
155            
156            while ( strstr(global_message_buffer1,"+WIND: 7") == 0 && global_time_counter < 10 ) ;  // Waiting for the modem to be ready
157    
158          reset_recieve_buffer();          reset_recieve_buffer();
159          sprintf(global_serial_send,"at+cgsn\r");          sprintf(global_serial_send,"at+cgsn\r");
160          serial_send();          serial_send();
         DelaySek(1);  
         //while(!global_recieve_done) ;  
161                    
162          while (global_has_imei == 0)          while (global_has_imei == 0)
163          {          {
# Line 166  void sms_init(void) Line 169  void sms_init(void)
169                                  buf[0] = global_message_buffer2[i];                                  buf[0] = global_message_buffer2[i];
170                                  buf[1] = 0;                                  buf[1] = 0;
171                                  global_imei_tversum += atoi(buf);                                  global_imei_tversum += atoi(buf);
                                 //global_imei_tversum += (global_message_buffer2[i] - '0');  
172                          }                          }
173                                                    
174                          global_has_imei = 1;                          global_has_imei = 1;
# Line 311  void send_sms(const unsigned char* paylo Line 313  void send_sms(const unsigned char* paylo
313          sprintf(global_serial_send, "%s%c", payload, 0x1A);          sprintf(global_serial_send, "%s%c", payload, 0x1A);
314          serial_send();          serial_send();
315          DelayMs(150);          DelayMs(150);
316                    if(global_sms_counter % 3 == 0)
317            {
318                    eeprom_writer();
319                    sprintf(global_serial_send, "at+cmgd=1,3\r");
320                    serial_send();
321                    while ( strstr(global_message_buffer1,"OK") == 0) ;
322            }
323  }        }      
324    
325  void convertTemp()  void convertTemp()
# Line 463  void main() Line 471  void main()
471          ad_init();          ad_init();
472          lcd_init(0);          lcd_init(0);
473          interrupt_init();          interrupt_init();
         sms_init();  
         //eeprom_init();  
474          timer_init();          timer_init();
475            sms_init();
476          eeprom_reader();          eeprom_reader();
477  ///////////////  ///////////////
478  // Main loop //  // Main loop //
# Line 478  void main() Line 485  void main()
485          while(1)          while(1)
486          {          {
487          // If there happends to be a critical state on the system, we send a sms.          // If there happends to be a critical state on the system, we send a sms.
488                  if( (global_temp >= 90 || PWRFAIL == 1 || FIREDET == 0 || FEEDING == 1 || EMPTYTANK == 1) && global_emergency_counter >= 600 )                  if( (global_temp >= 90 || PWRFAIL == 1 || FIREDET == 0 || FEEDING ==1 ) && global_emergency_counter >= 600 )
489                  {                  {
490                          send_update();                          send_update();
491                          global_emergency_counter = 0;                          global_emergency_counter = 0;

Legend:
Removed from v.172  
changed lines
  Added in v.173

  ViewVC Help
Powered by ViewVC 1.1.20