2017-02-16 20:55:33 +01:00
# include "BTKOM.h"
Bluetooth bluetooth ;
void listen ( ) {
2017-02-19 16:09:50 +01:00
bluetooth . receptMessage ( ) ;
2017-02-16 20:55:33 +01:00
}
int init ( ) {
int err = 0 ;
err = bluetooth . listen ( 2000 , 0 , listen , 1 ) ;
if ( err = = NOT_ENOUGH_RAM ) PrintMini ( 0 , 0 , ( const unsigned char * ) " Not enough RAM to start listening. " , 0 ) ;
else if ( err = = SERIAL_ALREADY_OPEN ) PrintMini ( 0 , 0 , ( const unsigned char * ) " Serial already open. " , 0 ) ;
bluetooth . setSender ( ( const char * ) " Xavier " ) ;
return ! err ;
}
2017-02-19 16:09:50 +01:00
int sendMessage ( const unsigned char type , const char * message ) {
2017-02-16 20:55:33 +01:00
int err = 0 ;
Message toSend ;
toSend . setType ( type ) ;
toSend . setMessage ( message ) ;
toSend . setSender ( ( const char * ) " Fuck " ) ;
err = bluetooth . sendMessage ( & toSend ) ;
//PrintMini(0,0,(const unsigned char*)itoa(err),0);
//PrintMini(1,1,(const unsigned char*)toSend.getSender(),0);
if ( err = = MISSING_ACK ) {
PrintMini ( 50 , 0 , ( const unsigned char * ) " Message sent " , 0 ) ;
} else if ( err = = UNKNOWN_ERROR ) {
PrintMini ( 50 , 0 , ( const unsigned char * ) " Unknown error " , 0 ) ;
}
return ! err ;
}
int main ( ) {
unsigned int key ;
char buffer [ ] = { " ok so this is gonna be a very long message to see the behavior even if I think it's gonna bug it will be funny then let's do it i need at least 100 more characters to see if it works corectly but I think i'm approximatly arriving to this objectif nevermind fuck this shit which doesn't work most of the time " } ;
ML_clear_screen ( ) ;
//ML_clear_vram();
if ( init ( ) ) {
2017-02-19 16:09:50 +01:00
sendMessage ( RQT , ( const char * ) buffer ) ;
2017-02-16 20:55:33 +01:00
}
//ML_display_vram();
//bluetooth.stop();
while ( 1 ) {
GetKey ( & key ) ;
}
return 1 ;
}