rssi test for 915

Dependencies:   libmDot915 mbed-rtos mbed

Fork of rssi_test by wireless sensor

Revision:
17:b60549bc8626
Parent:
16:847c028f4130
Child:
18:ee1ec5f500bf
--- a/main.cpp	Thu Feb 16 14:43:17 2017 +0000
+++ b/main.cpp	Thu Feb 16 17:34:37 2017 +0000
@@ -89,7 +89,7 @@
         sendCardID();
         
         /* wait a while */
-        wait(2);          
+        wait(1);          
     }
 }
 
@@ -236,14 +236,23 @@
     for(j=0; j<len; j++)str[j]=0;  
 }
 
+unsigned int get_F_position(char *str)
+{
+    unsigned int i=0;
+    while(str[i] != 'F')
+    {
+        i++;
+        if( i >6)break;
+    }
+    return i;
+}
+
 
 void readCardID(void)
 {
-      unsigned int i;
+      unsigned int i, p;
       char chr;
       
-      //pc.printf("Read Tick!\n\r");
-      
       /* clear the read buffer */
       my_strclear(readBuf, RESPONSE_LENGTH);
         
@@ -271,13 +280,14 @@
            pc.printf("%0X ", readBuf[i]);
            if (readBuf[i] == 0) break;
       } 
-      pc.printf("Response[Text]:%s\n\r", &readBuf[3]);
-      
-      /* add to ringBuffer if valid */
-    if((readBuf[3] != 0) && (readBuf[4] != 0)){ 
-      if((readBuf[3]!= '3') && (readBuf[4] !='C')) //valid response
+       
+      p = get_F_position(readBuf);
+      pc.printf("P=%d\n\r", p);
+      pc.printf("Response[Text]:%s\n\r", &readBuf[p+1]);
+      /* add to ringBuffer if valid */ 
+      if((p != 0) && (readBuf[p+1] != '3') && (readBuf[p+2] !='C')) //valid response
       {
-          my_strcpy(ringBuffer[inIndex], &readBuf[3]); //strim the 3 bytes prehead
+          my_strcpy(ringBuffer[inIndex], &readBuf[p+1]); //strim the 3 bytes prehead
           //pc.printf("addr = 0x%0X, inIndex = %d\n\r", &ringBuffer[inIndex],inIndex);
           inIndex++;
           if(inIndex >= RINGBUFFER_SIZE) inIndex = 0;
@@ -293,8 +303,7 @@
               
               wait(10); //in seconds
           }
-      }
-    }
+     }
 }
 
 void sendCardID(void)