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.
Revision 7:79c3ff270db1, committed 2016-01-26
- Comitter:
- hudakz
- Date:
- Tue Jan 26 23:16:31 2016 +0000
- Parent:
- 6:14d70104b0fc
- Commit message:
- Bug fixed.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file | 
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file | 
--- a/main.cpp	Tue Dec 15 19:34:51 2015 +0000
+++ b/main.cpp	Tue Jan 26 23:16:31 2016 +0000
@@ -295,64 +295,64 @@
             serial.printf("CRC error\r\n");
         } 
 #endif
-   
-        buf[i++] = 0x42;            // PDU type, given address is random; 0x42 for Android and 0x40 for iPhone
-        buf[i++] = 25;              // number of following data bytes, max 29  (CRC is not included)
+
+        for(ch = 0; ch < (sizeof(chRf) / sizeof(*chRf)); ch++) {
+            i = 0;
+            buf[i++] = 0x42;            // PDU type, given address is random; 0x42 for Android and 0x40 for iPhone
+            buf[i++] = 25;              // number of following data bytes, max 29  (CRC is not included)
+            
+            //----------------------------
+            buf[i++] = MY_MAC_0;
+            buf[i++] = MY_MAC_1;
+            buf[i++] = MY_MAC_2;
+            buf[i++] = MY_MAC_3;
+            buf[i++] = MY_MAC_4;
+            buf[i++] = MY_MAC_5;
         
-        //----------------------------
-        buf[i++] = MY_MAC_0;
-        buf[i++] = MY_MAC_1;
-        buf[i++] = MY_MAC_2;
-        buf[i++] = MY_MAC_3;
-        buf[i++] = MY_MAC_4;
-        buf[i++] = MY_MAC_5;
-    
-        buf[i++] = 2;               // flags (LE-only, limited discovery mode)
-        buf[i++] = 0x01;
-        buf[i++] = 0x05;
-    
-        buf[i++] = 9;               // length of the name, including type byte
-        buf[i++] = 0x08;            // TYPE_NAME_SHORT
-        buf[i++] = 'n';
-        buf[i++] = 'R';
-        buf[i++] = 'F';
-        buf[i++] = '2';
-        buf[i++] = '4';
-        buf[i++] = 'L';
-        buf[i++] = '0';
-        buf[i++] = '1';
+            buf[i++] = 2;               // flags (LE-only, limited discovery mode)
+            buf[i++] = 0x01;
+            buf[i++] = 0x05;
+        
+            buf[i++] = 9;               // length of the name, including type byte
+            buf[i++] = 0x08;            // TYPE_NAME_SHORT
+            buf[i++] = 'n';
+            buf[i++] = 'R';
+            buf[i++] = 'F';
+            buf[i++] = '2';
+            buf[i++] = '4';
+            buf[i++] = 'L';
+            buf[i++] = '0';
+            buf[i++] = '1';
+        
+            buf[i++] = 5;               // length of custom data, including type byte
+            buf[i++] = 0xff;            // TYPE_CUSTOMDATA
     
-        buf[i++] = 5;               // length of custom data, including type byte
-        buf[i++] = 0xff;            // TYPE_CUSTOMDATA
-
-        buf[i++] = data[0];         // temperature floating point value (four bytes)
-        buf[i++] = data[1];         
-        buf[i++] = data[2];         
-        buf[i++] = data[3];         
-        //----------------------------
+            buf[i++] = data[0];         // temperature floating point value (four bytes)
+            buf[i++] = data[1];         
+            buf[i++] = data[2];         
+            buf[i++] = data[3];         
+            //----------------------------
+            
+            buf[i++] = 0x55;            // CRC start value: 0x555555
+            buf[i++] = 0x55;
+            buf[i++] = 0x55;
         
-        buf[i++] = 0x55;            // CRC start value: 0x555555
-        buf[i++] = 0x55;
-        buf[i++] = 0x55;
-    
-        // Channel hopping
-        if(++ch == sizeof(chRf))
-            ch = 0;
-        nrfCmd(0x25, chRf[ch]);
-        nrfCmd(0x27, 0x6E);         // Clear flags
-        blePacketEncode(buf, i, chLe[ch]);
-        nrfWriteByte(0xE2);         // Clear RX Fifo
-        nrfWriteByte(0xE1);         // Clear TX Fifo
+            nrfCmd(0x25, chRf[ch]);
+            nrfCmd(0x27, 0x6E);         // Clear flags
+            blePacketEncode(buf, i, chLe[ch]);
+            nrfWriteByte(0xE2);         // Clear RX Fifo
+            nrfWriteByte(0xE1);         // Clear TX Fifo
+            
+            cs = 0;
+            spi.write(0xA0);
+            for(j = 0; j < i; j++)
+                spi.write(buf[j]);
+            cs = 1;
         
-        cs = 0;
-        spi.write(0xA0);
-        for(j = 0; j < i; j++)
-            spi.write(buf[j]);
-        cs = 1;
-    
-        nrfCmd(0x20, 0x12);         // TX on
-        ce = 1;                     // Enable Chip
-        wait_ms(50);    
-        ce = 0;                     // (in preparation of switching to RX quickly)
+            nrfCmd(0x20, 0x12);         // TX on
+            ce = 1;                     // Enable Chip
+            wait_ms(50);    
+            ce = 0;                     // (in preparation of switching to RX quickly)
+        }
     }
 }
--- a/mbed.bld Tue Dec 15 19:34:51 2015 +0000 +++ b/mbed.bld Tue Jan 26 23:16:31 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96 \ No newline at end of file