
save
Dependencies: BLE_API TMP102 mbed nRF51822
Revision 0:6d3d0dc59210, committed 2016-06-02
- Comitter:
- nakamae
- Date:
- Thu Jun 02 15:43:59 2016 +0000
- Commit message:
- save;
Changed in this revision
diff -r 000000000000 -r 6d3d0dc59210 BLE_API.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BLE_API.lib Thu Jun 02 15:43:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#66159681aa21
diff -r 000000000000 -r 6d3d0dc59210 TMP102.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TMP102.lib Thu Jun 02 15:43:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/chris/code/TMP102/#694792b93731
diff -r 000000000000 -r 6d3d0dc59210 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 02 15:43:59 2016 +0000 @@ -0,0 +1,81 @@ +#include "mbed.h" +#include "BLE.h" +#include "HeartRateService.h" +#include "DeviceInformationService.h" + + +#define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console; +* it will have an impact on code-size and power consumption. */ + +#if NEED_CONSOLE_OUTPUT +Serial pc(USBTX, USBRX); +#define DEBUG(...) { pc.printf(__VA_ARGS__); } +#else +#define DEBUG(...) /* nothing */ +#endif /* #if NEED_CONSOLE_OUTPUT */ + +BLE ble; +int address[5][5]={}; + +int counter= 0; +void onScanCallback(const Gap::AdvertisementCallbackParams_t *params) +{ + + int i=0,a=0,b=0,flag=0; +#if NEED_CONSOLE_OUTPUT + // DEBUG("onScan() "); + // DEBUG("RSSI:%d ",params->rssi); + // DEBUG("Addr:%d ",params->peerAddr); + // DEBUG("adv peerAddr[%02x %02x %02x %02x %02x %02x]", params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1],params->peerAddr[0]); + for(i=0;i<6;i++){ + if(address[i][0]==params->peerAddr[5]){ + flag=1; + break; + } + } + + if(flag==0){ + for(i=0; i<6; i++){ + // DEBUG("Scn(%02x)",params->peerAddr[i]); + address[counter][i]=params->peerAddr[5-i]; + } + counter++; + //DEBUG("Len:%d ",params->advertisingDataLen); + //DEBUG("Data:"); + //for (int i=0; i< params->advertisingDataLen; i++){ + // DEBUG("%02x,",params->advertisingData[i]); + // } + // DEBUG(" \n\r"); + for(a=0; a<counter; a++){ + for(b=0; b<6 ; b++){ + if(b==0)DEBUG("DEV:"); + DEBUG("%02x ", address[a][b]); + if(b==5)DEBUG("\n\r"); + } + if(a==counter-1)DEBUG("----------\n\r"); + } + wait(3); + } +#endif + + +} + +const GapScanningParams scanningParams; +int main(void) +{ + + + ble.init(); + DEBUG("Start\n\r"); + + ble.setScanParams(GapScanningParams::SCAN_INTERVAL_MAX, + GapScanningParams::SCAN_WINDOW_MAX, + 0); + + ble.startScan(&onScanCallback); + // infinite loop + while (1) { + ble.waitForEvent(); // low power wait for event + } +}
diff -r 000000000000 -r 6d3d0dc59210 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jun 02 15:43:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file
diff -r 000000000000 -r 6d3d0dc59210 nRF51822.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nRF51822.lib Thu Jun 02 15:43:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#f7faad332abc