med ble switch science
Dependencies: BLE_API SDFileSystem mbed-rtos mbed nRF51822
Diff: main.cpp
- Revision:
- 3:8fcc0e904fd6
- Parent:
- 2:592364ca5fb2
- Child:
- 4:c1ac302982b7
--- a/main.cpp Tue Oct 25 05:32:14 2016 +0000 +++ b/main.cpp Tue Oct 25 08:55:43 2016 +0000 @@ -24,6 +24,7 @@ const GapScanningParams scanningParams; int wt;//threadの時間 int wt1=0;//central mode の時間 +int ran; SDFileSystem sd(p25, p28, p29, p21, "sd"); // the pinout on the mbed Cool Components workshop board FILE *fp; @@ -96,7 +97,7 @@ if(!strcmp((const char*)name, "1")){ printf("**startAdvertising thread**\n\r"); - wt=2000; + wt=1000; ble.gap().stopAdvertising(); ble.startScan(&onScanCallback); } @@ -104,8 +105,9 @@ if(!strcmp((const char*)name, "2")){ printf("**send thread**\n\r"); myled3 = 1; - wt=SEND_TIME; - //printf("%d秒間の送信\n\r",wt/1000); + ran = rand() % 10; + wt=SEND_TIME - ran*1000; + printf("%d秒間の送信\n\r",wt/1000); ble.gap().startAdvertising();//BLEの送信 } @@ -116,11 +118,12 @@ counter = 0; printf("**get thread**\n\r"); myled3 = 0; + //ran = rand() % 5; wt=0;//central modeの際はthreadの時間は0sec - wt1 = GET_TIME;//centralmode の時間はこっち + wt1 = GET_TIME ;//centralmode の時間はこっち fp = fopen("/sd/test.csv", "a"); - //printf("%d秒間の受信\n\r",wt1/1000); + printf("%d秒間の受信\n\r",wt1/1000); // printf("before\n\r"); timer.start(); //printf("after\n\r");