Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Revision:
20:2b6ebe60929d
Parent:
16:50686c07ad07
diff -r 3e3b03d80ea3 -r 2b6ebe60929d serial.cpp
--- a/serial.cpp	Mon Jun 05 22:47:14 2017 +0000
+++ b/serial.cpp	Mon Jul 08 10:50:40 2019 +0000
@@ -55,11 +55,11 @@
 {
     if(ENABLE_PC_SERIAL) {
         pc.baud(PC_BAUD);
-        pc.attach(this,&SerialControl::IF_pc_rx_callback, Serial::RxIrq);
+        pc.attach(callback(this, &SerialControl::IF_pc_rx_callback), Serial::RxIrq);
     }
     if(ENABLE_BLUETOOTH) {
         bt.baud(BLUETOOTH_BAUD);
-        bt.attach(this,&SerialControl::IF_bt_rx_callback, Serial::RxIrq);
+        bt.attach(callback(this, &SerialControl::IF_bt_rx_callback), Serial::RxIrq);
     }
 }
 
@@ -77,7 +77,7 @@
     file_length = 0;
     user_code_restore_mode = user_code_running;
     user_code_running = 0;
-    ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,2.0);
+    ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 2.0);
 }
 
 
@@ -138,7 +138,7 @@
                     psi.debug("Target filename:%s\n",filename);
                     //Send acknowledge ("FN")
                     ft_timeout.detach();
-                    ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,2.0);
+                    ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 2.0);
                     bt.printf("%c%c%s",RESPONSE_MESSAGE_BYTE,2,"FN");
                     file_transfer_state = 1;
                 }
@@ -171,7 +171,7 @@
                     //file_data = (char *) malloc(target_size);
                     psi.debug("File size %d bytes (%d blocks of %d bytes)\n",file_length,final_block,block_size);
                     ft_timeout.detach();
-                    ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,1.0);
+                    ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 1.0);
                     //Send acknowledge (size of file)
                     bt.printf("%c%c%c%c%c",RESPONSE_MESSAGE_BYTE,3,message[1],message[2],message[3]);
                 }
@@ -209,7 +209,7 @@
                         psi.debug("Message packet %d received and written\n",block_index);
                         //Send acknowledge ("D")
                         ft_timeout.detach();
-                        ft_timeout.attach(this,&SerialControl::IF_file_transfer_timeout,1.0);
+                        ft_timeout.attach(callback(this, &SerialControl::IF_file_transfer_timeout), 1.0);
                         bt.printf("%c%c%s",RESPONSE_MESSAGE_BYTE,1,"D");
                     } else {
                         //Last data block written
@@ -1168,7 +1168,7 @@
         } else {
             if(count == 1) {
                 if(tc == COMMAND_MESSAGE_BYTE) {
-                    pc_command_timeout.attach(this,&SerialControl::IF_pc_rx_command_timeout,command_timeout_period);
+                    pc_command_timeout.attach(callback(this, &SerialControl::IF_pc_rx_command_timeout), command_timeout_period);
                     pc_command_message_started = 1;
                     pc_command_message_byte = 0;
 
@@ -1321,7 +1321,7 @@
                     count = 5;
                 }
             } else {
-                bt_command_timeout.attach(this,&SerialControl::IF_bt_rx_command_timeout,command_timeout_period);
+                bt_command_timeout.attach(callback(this, &SerialControl::IF_bt_rx_command_timeout), command_timeout_period);
                 bt_command_message[bt_command_message_byte] = tc;
                 bt_command_message_byte ++;
             }