Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
33:f9a542d3efaa
Parent:
32:1e8d2d1c2946
Child:
34:1311cc53201a
--- a/src/d7a_modem.cpp	Thu Jun 16 12:10:10 2016 +0000
+++ b/src/d7a_modem.cpp	Fri Jun 24 10:11:19 2016 +0000
@@ -43,8 +43,6 @@
         g_modem_ctx.reset = new DigitalInOut(reset_pin, PIN_OUTPUT, OpenDrain, 0);
     }
     
-    Thread::wait(10);
-    
     d7a_modem_reset();
     
     // Wait for modem ready
@@ -62,6 +60,9 @@
     {
         // Try software reset
         d7a_sys_software_reset();
+        
+        // Clean reception buffer
+        d7a_com_flush_rx();
     }
     else
     {
@@ -69,6 +70,10 @@
         // Assert reset pin
         *(g_modem_ctx.reset) = 0;
         Thread::wait(10);
+        
+        // Clean reception buffer
+        d7a_com_flush_rx();
+        
         // Release reset pin
         *(g_modem_ctx.reset) = 1;
         Thread::wait(10);
@@ -111,7 +116,7 @@
 
 bool d7a_modem_register_file(uint8_t fid, uint8_t retry_policy)
 {
-    g_modem_ctx.ressource->wait();
+    //g_modem_ctx.ressource->wait();
     
     bool ret = true;
     
@@ -148,14 +153,14 @@
     }
     
     DPRINT("Register done.\r\n");
-    g_modem_ctx.ressource->release();
+    //g_modem_ctx.ressource->release();
     
     return ret;
 }
 
 void d7a_modem_notify_file(uint8_t fid, uint32_t offset, uint32_t length)
 {
-    g_modem_ctx.ressource->wait();
+    //g_modem_ctx.ressource->wait();
     
     FPRINT("(fid:%d, offset:%d, length:%d)\r\n", fid, offset, length);
     DPRINT("Notify %d.\r\n", fid);
@@ -172,7 +177,7 @@
     //Thread::wait(100); // XXX: To avoid lost packets
     
     DPRINT("Notify %d done.\r\n", fid);
-    g_modem_ctx.ressource->release();
+    //g_modem_ctx.ressource->release();
 }
 
 void d7a_modem_print_infos( void )
@@ -180,7 +185,7 @@
     uint8_t uid[8];
     revision_t rev;
     
-    g_modem_ctx.ressource->wait();
+    //g_modem_ctx.ressource->wait();
     
     d7a_fs_read(0, uid, 0, 8);
     d7a_fs_wait_done(TO_FS);
@@ -197,7 +202,7 @@
     PRINT("| File system CRC:  0x%08x          |\r\n", rev.fs_crc);
     PRINT("-----------------------------------------\r\n");
     
-    g_modem_ctx.ressource->release();
+    //g_modem_ctx.ressource->release();
 }