med ble switch science

Dependencies:   BLE_API SDFileSystem mbed-rtos mbed nRF51822

Revision:
4:c1ac302982b7
Parent:
3:8fcc0e904fd6
Child:
5:f8734ee36ec9
--- a/main.cpp	Tue Oct 25 08:55:43 2016 +0000
+++ b/main.cpp	Thu Nov 03 03:08:11 2016 +0000
@@ -6,8 +6,8 @@
 #include "rtos.h"
 #include <string.h>
 #include "SDFileSystem.h"
-#define n 100//addressを保存する個数
-#define m 12//addressとtimeを入れる
+#define N 100//addressを保存する個数
+#define M 12//addressとtimeを入れる
 #define GET_TIME 10000
 #define SEND_TIME 20000
 #define AA 0xAA
@@ -20,7 +20,7 @@
  
  Timer timer;
 BLE  ble;
-char address[n][m]={};//保存する配列を初期化
+char address[N][M]={};//保存する配列を初期化
 const GapScanningParams scanningParams;
 int wt;//threadの時間
 int wt1=0;//central mode の時間
@@ -59,15 +59,28 @@
         address[counter][10]= t->tm_min;
         address[counter][11]= t->tm_sec;
     
-        //fprintf(fp,"DEV:");
-        //printf("DEV:");
         for(b=0; b<6 ; b++){
             fprintf(fp,"%02x", address[counter][b]);
             printf("%02x", address[counter][b]);
+            if(b==5)printf(" ");
         }    
-        fprintf(fp,",%04d,%02d,%02d,%02d,%02d,%02d\n",address[counter][6],address[counter][7],address[counter][8],address[counter][9],address[counter][10],address[counter][11]);
-        printf(",%04d/%02d/%02d %02d:%02d:%02d\r\n",address[counter][6],address[counter][7],address[counter][8],address[counter][9],address[counter][10],address[counter][11]);
+        
+        fprintf(fp,",%04d",address[counter][b]);
+        b++;
+        
+        for(; b<12; b++){
+            fprintf(fp,"%02d",address[counter][b]);
+            printf("%02d",address[counter][b]);
+            if(b==11){
+                fprintf(fp,"\n");
+                printf("\r\n");
+            }
+        }  
+        //fprintf(fp,",%04d,%02d,%02d,%02d,%02d,%02d\n",address[counter][6],address[counter][7],address[counter][8],address[counter][9],address[counter][10],address[counter][11]);
+        //printf(",%04d/%02d/%02d %02d:%02d:%02d\r\n",address[counter][6],address[counter][7],address[counter][8],address[counter][9],address[counter][10],address[counter][11]);
+        
         counter++;
+
 /*      
         printf("DEV:");
         for(b=0; b<6 ; b++)printf("%02x ", address[counter][b]);   
@@ -96,14 +109,14 @@
         one_slot.wait();
         
         if(!strcmp((const char*)name, "1")){
-            printf("**startAdvertising thread**\n\r");
+            //printf("**startAdvertising thread**\n\r");
             wt=1000;
             ble.gap().stopAdvertising();
             ble.startScan(&onScanCallback);
         }
 //2        
         if(!strcmp((const char*)name, "2")){
-            printf("**send thread**\n\r"); 
+            printf("**send**\n\r"); 
             myled3 = 1;
             ran = rand() % 10;
             wt=SEND_TIME - ran*1000;
@@ -116,9 +129,8 @@
         //timer.reset();
             memset(address, 0, sizeof(address));//配列の初期化
             counter = 0;
-            printf("**get thread**\n\r");
+            printf("**get**\n\r");
             myled3 = 0;
-            //ran = rand() % 5; 
             wt=0;//central modeの際はthreadの時間は0sec
             wt1 = GET_TIME ;//centralmode の時間はこっち
             fp = fopen("/sd/test.csv", "a");