mirror of
				https://github.com/Oleg-Stepanenko-owo/IEBUS
				synced 2025-10-28 00:47:17 +00:00 
			
		
		
		
	added commands log on\off for BT
This commit is contained in:
		
							parent
							
								
									b87cc0fcaf
								
							
						
					
					
						commit
						50d76d478e
					
				| @ -4,13 +4,19 @@ | |||||||
| #include <avr/pgmspace.h> | #include <avr/pgmspace.h> | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| SoftwareSerial mySerial(4, 3); // RX | TX
 | SoftwareSerial mySerial(4, 3); // RX | TX
 | ||||||
| 
 | char command_buff[15]; | ||||||
|  | int command_i; | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| void AVCLanBT::begin() | void AVCLanBT::begin() | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| { | { | ||||||
|   mySerial.begin(9600); |   mySerial.begin(9600); | ||||||
|   mySerial.println("BlueTooth is ready"); |   mySerial.println("BlueTooth is ready"); | ||||||
|  |   mySerial.println("log_on@ - start logging"); | ||||||
|  |   mySerial.println("log_off@ - end logging"); | ||||||
|  |   mySerial.println("save@ - save logging in EEPROM"); | ||||||
|  |   logging = false; | ||||||
|  |   command_i = 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| @ -18,7 +24,6 @@ void AVCLanBT::println( char* val ) | |||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| { | { | ||||||
|   mySerial.println( val ); |   mySerial.println( val ); | ||||||
|   mySerial.println( "\n\r" ); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| @ -28,6 +33,47 @@ void AVCLanBT::print( const char* val ) | |||||||
|   mySerial.print( val ); |   mySerial.print( val ); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | char AVCLanBT::read() | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | { | ||||||
|  |   return mySerial.read(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | bool AVCLanBT::isLogging() | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | { | ||||||
|  |   return logging; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | int AVCLanBT::available() | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | { | ||||||
|  |   return mySerial.available(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | void AVCLanBT::checkCommand( char command ) | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
|  | { | ||||||
|  |   if ( command == '@' ) //end of command;
 | ||||||
|  |   { | ||||||
|  |     command_buff[command_i + 1] = '\0'; | ||||||
|  |     command_i = 0; | ||||||
|  | 
 | ||||||
|  |     if ( 0 == strcmp( command_buff, "log_on" )  ) logging = true; | ||||||
|  |     else if ( 0 == strcmp( command_buff, "log_off" )  ) logging = false; | ||||||
|  |     println(command_buff); | ||||||
|  |     Serial.print("logging - "); Serial.println(logging); | ||||||
|  |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     command_buff[command_i++] = command; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| AVCLanBT avclanBT; | AVCLanBT avclanBT; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,7 +18,14 @@ class AVCLanBT | |||||||
|     void println( char*); |     void println( char*); | ||||||
|     void print(const char*); |     void print(const char*); | ||||||
| 
 | 
 | ||||||
|  |     char read(); | ||||||
|  | 
 | ||||||
|  |     bool isLogging(); | ||||||
|  |     int available(); | ||||||
|  |     void checkCommand(char command ); | ||||||
|  | 
 | ||||||
|   private: |   private: | ||||||
|  |     bool logging; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| extern AVCLanBT avclanBT; | extern AVCLanBT avclanBT; | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| 
 | 
 | ||||||
|  | //--------------------------------------------------------------------------------
 | ||||||
| #include "AVCLanDrv.h" | #include "AVCLanDrv.h" | ||||||
| #include "AVCLanHonda.h" | #include "AVCLanHonda.h" | ||||||
| #include "AVCLan_BT.h" | #include "AVCLan_BT.h" | ||||||
| #include "config.h" | #include "config.h" | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| 
 | 
 | ||||||
| //--------------------------------------------------------------------------------
 |  | ||||||
| #define LED_ON   sbi(LED_PORT, LED_OUT); | #define LED_ON   sbi(LED_PORT, LED_OUT); | ||||||
| #define LED_OFF  cbi(LED_PORT, LED_OUT); | #define LED_OFF  cbi(LED_PORT, LED_OUT); | ||||||
| 
 | 
 | ||||||
| @ -16,10 +16,15 @@ static int MAX_ERROR_COUNT = 30; | |||||||
| byte errorID; | byte errorID; | ||||||
| int  error_count; | int  error_count; | ||||||
| char BUFFF[15]; | char BUFFF[15]; | ||||||
|  | 
 | ||||||
|  | char buf[12]; //buffer to store AT commands
 | ||||||
|  | int len = 0; //stores the length of the commands
 | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| void setup() | void setup() | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| { | { | ||||||
|  |   Serial.begin(9600); | ||||||
|  | 
 | ||||||
|   avclan.begin(); |   avclan.begin(); | ||||||
|   avclanHonda.begin(); |   avclanHonda.begin(); | ||||||
|   errorID = 0; |   errorID = 0; | ||||||
| @ -34,6 +39,17 @@ void setup() | |||||||
| void loop() | void loop() | ||||||
| //--------------------------------------------------------------------------------
 | //--------------------------------------------------------------------------------
 | ||||||
| { | { | ||||||
|  |   if (avclanBT.available()) | ||||||
|  |   { | ||||||
|  |     len = avclanBT.available(); | ||||||
|  |     int i; | ||||||
|  |     Serial.print("len ="); Serial.println(len); | ||||||
|  |     for (i = 0; i < len; i++) | ||||||
|  |     { | ||||||
|  |       avclanBT.checkCommand(avclanBT.read()); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   if ( avclanHonda.bFirstStart_20 && (11500 > millis()) ) { |   if ( avclanHonda.bFirstStart_20 && (11500 > millis()) ) { | ||||||
|     HONDA_DIS_ON;  // initalize
 |     HONDA_DIS_ON;  // initalize
 | ||||||
|     return; |     return; | ||||||
|  | |||||||
| @ -39,11 +39,6 @@ | |||||||
| #define LED_OUT		5 | #define LED_OUT		5 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // AZFM board activate
 |  | ||||||
| //#define AZFM_INIT
 |  | ||||||
| //#define AZFM_ON
 |  | ||||||
| //#define AZFM_OFF
 |  | ||||||
| 
 |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user