55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include "BTKOM.h"
|
|
|
|
Bluetooth bluetooth;
|
|
|
|
void listen(){
|
|
bluetooth.receptMessage();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
int sendMessage(const unsigned char type, const char* message){
|
|
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()){
|
|
sendMessage(RQT,(const char*) buffer);
|
|
}
|
|
//ML_display_vram();
|
|
//bluetooth.stop();
|
|
while(1){
|
|
GetKey(&key);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
|