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.
Diff: main.cpp
- Revision:
- 5:d5349e68b9f8
- Parent:
- 4:04351e4aad49
diff -r 04351e4aad49 -r d5349e68b9f8 main.cpp
--- a/main.cpp Mon Feb 13 19:47:34 2017 +0000
+++ b/main.cpp Mon Feb 13 19:54:49 2017 +0000
@@ -8,18 +8,6 @@
Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);
-int CalculateChecksum()
-{
- // Does not include frame delimiter and lenght
- return 1;
-}
-
-int CalculateLenght()
-{
- // Calculate the number of bytes in the frame data
- return 1;
-}
-
void printhexa(char c)
{
char msb = c >> 4;
@@ -110,7 +98,7 @@
*ans = status;
}
-char* GetATResponse()
+char* InterpretMessage()
{
char start = xbee.getc(); // = FRAMEDELIMITER
//assert
@@ -129,7 +117,6 @@
case 0x88: ATCommandResponse(len, response);
break;
case 0x8A: ModemStatus(len, response);
- pc.printf(response);
break;
default: pc.printf("Please implement response of type");
printhexa(type);
@@ -139,48 +126,7 @@
return response;
}
-
-void ReadSerial()
-{
- // 00 13 A2 00
- // 40 3E 09 63
- char cmdtosend[8];
- int i = 0;
-
- cmdtosend[0] = FRAMEDELIMITER;
- cmdtosend[1] = 0x00;
- cmdtosend[2] = 0x04;
- cmdtosend[3] = 0x08;
- cmdtosend[4] = 0x52;
- cmdtosend[5] = 'S'; // 0x53
- cmdtosend[6] = 'H'; // 0x48
- cmdtosend[7] = 0xFF - (cmdtosend[3]+cmdtosend[4]+cmdtosend[5]+cmdtosend[6]);
-
- while (i < 8)
- {
- xbee.putc(cmdtosend[i]);
- i++;
- }
-
- wait(0.5);
- i = 0;
- cmdtosend[0] = FRAMEDELIMITER;
- cmdtosend[1] = 0x00;
- cmdtosend[2] = 0x04;
- cmdtosend[3] = 0x08;
- cmdtosend[4] = 0x52;
- cmdtosend[5] = 'S'; // 0x53
- cmdtosend[6] = 'L'; // 0x48
- cmdtosend[7] = 0xFF - (cmdtosend[3]+cmdtosend[4]+cmdtosend[5]+cmdtosend[6]);
-
- while (i < 8)
- {
- xbee.putc(cmdtosend[i]);
- i++;
- }
-}
-
-void AtCommand(char FirstChar, char SecondChar, char *OptionalParam = NULL, int ParamLen = 0)
+void SendAtCommand(char FirstChar, char SecondChar, char *OptionalParam = NULL, int ParamLen = 0)
{
// Frame Type 0x08
// Two char as parameters
@@ -229,8 +175,17 @@
xbee.putc(cmdtosend[i]);
i++;
}
+
+ wait(0.1);
}
+void ReadSerial()
+{
+ // 00 13 A2 00
+ // 40 3E 09 63
+ SendAtCommand('S', 'H');
+ SendAtCommand('S', 'L');
+}
void xbee_reader()
{
@@ -238,7 +193,7 @@
{
if (xbee.readable())
{
- GetATResponse();
+ InterpretMessage();
}
wait(0.001);
}
@@ -259,18 +214,7 @@
resetswitch = 1;
wait(3);
-
- char Params[2] = {'a', 'b'};
-
ReadSerial();
- wait(0.5);
- AtCommand('O', 'I');
- wait(0.5);
- AtCommand('I', 'I', &Params[0], 2);
- wait(0.5);
- AtCommand('O', 'I');
- wait(0.5);
-
while(1) {
}