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.
Dependencies: mbed ConfigFile
Fork of app4-router by
main.cpp
- Committer:
- trixrabbit
- Date:
- 2014-02-22
- Revision:
- 2:bbe1253008e6
- Parent:
- 1:568707763458
- Child:
- 3:ef0e12857e30
File content as of revision 2:bbe1253008e6:
#include "mbed.h"
#include <string>
#define ACCEL 0x01
#define PUSHBOUTON 0x02
DigitalOut myled(LED1);
DigitalOut myled2(LED2);
DigitalOut reset(p8);
Serial pc(USBTX, USBRX);
Serial xbee(p13, p14);
string data = "allo bonjour";
// 7E 00 0F 10 01 00 13 A2 00 40 8B 41 98 00 00 00 00 33 62
// 7E 00 10 10 01 00 13 A2 00 40 8B 41 98 00 00 00 00 33 33 2F
void checksum()
{
}
void xbee_transmit(char type, string data)
{
char checkSum = 0;
char size = data.length() + 0x0E; //0x0E + data type + nombre de data = 0x0F + nombre de data
xbee.putc(0x7E); // start delimeter
xbee.putc(0x00); // length
xbee.putc(size); // length
xbee.putc(0x10); // frame type
xbee.putc(0x01); // frame ID
xbee.putc(0x00); // adress MAC debut
xbee.putc(0x13); // |
xbee.putc(0xA2); // |
xbee.putc(0x00); // |
xbee.putc(0x40); // |
xbee.putc(0x8B); // |
xbee.putc(0x41); // |
xbee.putc(0x98); // adress MAC fin
xbee.putc(0x00); // dest. adress network
xbee.putc(0x00); // dest. adress network
xbee.putc(0x00); // broadcast radius
xbee.putc(0x00); // option
checkSum = checkSum + 0x10 + 0x01 + 0x00 + 0x13+ 0xA2 + 0x00 + 0x40 + 0x8B +0x41 + 0x98 + 0x00 + 0x00 + 0x00 + 0x00;
//data type
for (int i=0;i<data.length();i++) //data
{
xbee.putc(data[i]);
checkSum += data[i];
}
checkSum = 0xff - checkSum;
pc.printf(" check sum = %x" , checkSum);
xbee.putc(checkSum); // checksum
}
int main()
{
myled = 1;
myled2 = 1;
reset = 0;
wait_ms(400);
reset = 1;
myled = 0;
myled2 = 0;
while(1)
{
wait(4);
xbee_transmit(ACCEL, data);
/* if(xbee.readable())
{
pc.putc(xbee.getc());
myled2 = ! myled2;
}
if(pc.readable())
{
xbee.putc(pc.getc());
myled = ! myled;
}*/
}
}
