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 master_firmware_042716 by
Diff: main.cpp
- Revision:
- 2:3a3260cd7215
- Parent:
- 1:90eadb418638
--- a/main.cpp Thu Apr 28 04:06:32 2016 +0000
+++ b/main.cpp Thu Apr 28 21:42:18 2016 +0000
@@ -21,13 +21,14 @@
bool master_manual = false;
bool slave_manual = false;
+string masterMode = "";
+string slaveMode = "";
string received = "";
string sent = "";
//string wifi_receive = ""; //data recieved from Feather
string wifi_sent = ""; //data sent to the Feather
+string slave_status = "";
-string masterMode = "";
-string slaveMode = "";
int sDimAmt = 0;
int mDimAmt = 0;
@@ -39,7 +40,11 @@
bool receiveComplete = false;
bool decodeComplete = false;
+bool xbee_read_done = false;
+bool xbee_decode_done = false;
+bool xbee_status_send = false;
char wifi_message [16] = {'M','A','0','0','0','0','0','0','S','A','0','0','0','0','0','0'};
+char xbee_buffer [8] = {};
//Thread for receiving data
void wifi_receive(void const *args) {
@@ -100,6 +105,7 @@
//SET mutex for wifi action HERE
decodeComplete = true;
+ xbee_status_send = true;
}
}
@@ -149,10 +155,56 @@
} //END superloop
} //END thread light_status_update
+void xbee_receive(void const *args) {
+ while (1) {
+ while (XBEE.readable())
+ {
+ int i = 0;
+ char temp;
+ temp = XBEE.getc();
+ xbee_buffer [i] = temp;
+ i = i + 1;
+ osDelay(10);
+
+ }
+
+ xbee_read_done = true;
+ pc.printf(xbee_buffer); // DEBUGGING purposes
+
+ } //END superloop
+} //END xbee_receive
+
+void xbee_decode(void const *args) {
+ while (1) {
+ if(xbee_read_done)
+ {
+ xbee_read_done = false;
+ slave_status = (string)xbee_buffer;
+ xbee_decode_done = true;
+ }
+ osDelay(30);
+ } //END superloop
+} //END xbee_decode
+
+void xbee_action(void const *args)
+{
+ while (1) {
+ if( xbee_status_send ) //FILL IN wifi message decode
+ {
+ XBEE.printf("SA%03d%03d",sDimAmt,sTemp);
+ xbee_status_send = false;
+ }
+ osDelay(30);
+ }//END superloop
+} //END xbee_action
+
osThreadDef(wifi_receive, osPriorityNormal, DEFAULT_STACK_SIZE);
osThreadDef(wifi_decode, osPriorityNormal, DEFAULT_STACK_SIZE);
osThreadDef(wifi_action, osPriorityNormal, DEFAULT_STACK_SIZE);
osThreadDef(light_status_update, osPriorityNormal, DEFAULT_STACK_SIZE);
+osThreadDef(xbee_receive, osPriorityNormal, DEFAULT_STACK_SIZE);
+osThreadDef(xbee_decode, osPriorityNormal, DEFAULT_STACK_SIZE);
+osThreadDef(xbee_action, osPriorityNormal, DEFAULT_STACK_SIZE);
int main ()
{
@@ -160,6 +212,9 @@
osThreadCreate(osThread(wifi_decode),NULL);
osThreadCreate(osThread(wifi_action),NULL);
osThreadCreate(osThread(light_status_update),NULL);
+ osThreadCreate(osThread(xbee_receive),NULL);
+ osThreadCreate(osThread(xbee_decode),NULL);
+ osThreadCreate(osThread(xbee_action),NULL);
pc.baud(115200);
wifi.baud(115200);
XBEE.baud(115200);
