Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of KNX1 by
Revision 1:c23498fff229, committed 2018-01-05
- Comitter:
- Caelum
- Date:
- Fri Jan 05 13:50:02 2018 +0000
- Parent:
- 0:31e48fd9d8da
- Commit message:
- Le travail sur KNX
Changed in this revision
recept_xbee.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 31e48fd9d8da -r c23498fff229 recept_xbee.cpp --- a/recept_xbee.cpp Wed Dec 06 13:38:52 2017 +0000 +++ b/recept_xbee.cpp Fri Jan 05 13:50:02 2018 +0000 @@ -4,36 +4,86 @@ DigitalOut myled(LED2); Serial knx(PA_9,PA_10); //Initalise xbee_lib Serial pc(USBTX, USBRX); //Initalise PC serial comms +Serial bluetooth(PB_10,PB_11); DigitalIn mybutton(USER_BUTTON); int hexa =0xBC; -int TABHEXA[18]={0x80,0xBC,0x81,0x11,0x82,0x01,0x83,0x00,0x84,0x01,0x85,0xE1,0x86,0x00,0x87,0x81,0x48,0x32}; +int ALLUMMER_C1[18]={0x80,0xBC,0x81,0x11,0x82,0x01,0x83,0x00,0x84,0x01,0x85,0xE1,0x86,0x00,0x87,0x81,0x48,0x32}; +int ETEINDRE_C1[18]={0x80,0xBC,0x81,0x11,0x82,0x01,0x83,0x00,0x84,0x01,0x85,0xE1,0x86,0x00,0x87,0x80,0x48,0x33}; +int ALLUMMER_C2[18]={0x80,0xBC,0x81,0x11,0x82,0x01,0x83,0x00,0x84,0x03,0x85,0xE1,0x86,0x00,0x87,0x81,0x48,0x30}; +int ETEINDRE_C2[18]={0x80,0xBC,0x81,0x11,0x82,0x01,0x83,0x00,0x84,0x03,0x85,0xE1,0x86,0x00,0x87,0x80,0x48,0x31}; +int OUVRIR[18]={0x80,0xBC,0x81,0x11,0x82,0x0C,0x83,0x08,0x84,0x00,0x85,0xE1,0x86,0x00,0x87,0x80,0x48,0x37}; +int FERMER[18]={0x80,0xBC,0x81,0x11,0x82,0x0C,0x83,0x08,0x84,0x00,0x85,0xE1,0x86,0x00,0x87,0x81,0x48,0x36}; int i; - +int loop = 0; +char receive; int main() { -knx.format(9,SerialBase::Even,1); -//pc.format(8,SerialBase::Odd,1); -knx.baud(19200); -pc.baud(19200); - + knx.format(9,SerialBase::Even,1); + //pc.format(8,SerialBase::Odd,1); + knx.baud(19200); + pc.baud(19200); + bluetooth.baud(9600); while(1) { - - - if (mybutton == 0)//Button is pressed - { - for(i=0;i<19;i++){ - knx.putc(TABHEXA[i]); - //pc.putc(TABHEXA[i]); - myled = !myled; - wait(0.001); - } - i =0; - wait(1); - -} + while(bluetooth.readable()){ + myled = !myled; + receive = bluetooth.getc(); + wait(1); + switch(receive){ + case '0': + for(i=0;i<19;i++){ + knx.putc(ALLUMMER_C1[i]); + //pc.putc(TABHEXA[i]); + myled = !myled; + wait(0.001); + } + break; + case '3': + for(i=0;i<19;i++){ + knx.putc(ETEINDRE_C2[i]); + //pc.putc(TABHEXA[i]); + myled = !myled; + wait(0.001); + } + break; + case '1': + for(i=0;i<19;i++){ + knx.putc(ETEINDRE_C1[i]); + //pc.putc(TABHEXA[i]); + myled = !myled; + wait(0.001); + } + break; + case '2': + for(i=0;i<19;i++){ + knx.putc(ALLUMMER_C2[i]); + //pc.putc(TABHEXA[i]); + myled = !myled; + wait(0.001); + } + break; + case '4': + for(i=0;i<19;i++){ + knx.putc(OUVRIR[i]); + //pc.putc(TABHEXA[i]); + myled = !myled; + wait(0.001); + } + break; + case '5': + for(i=0;i<19;i++){ + knx.putc(FERMER[i]); + //pc.putc(TABHEXA[i]); + myled = !myled; + wait(0.001); + } + break; + default: + //rien + break; + } + } + } } -} -