UpdatedDecryp
Dependencies: BahlDecrypModified CyaSSL mbed nRF51822
Fork of Decryptulator by
main.cpp@4:dd8231564124, 2015-06-19 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Jun 19 23:41:09 2015 +0000
- Revision:
- 4:dd8231564124
- Parent:
- 3:50a7d47912b2
- Child:
- 5:103717ce54e5
updating to the latest of the underlying libraries.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 0:332983584a9c | 1 | /* mbed Microcontroller Library |
rgrover1 | 0:332983584a9c | 2 | * Copyright (c) 2006-2015 ARM Limited |
rgrover1 | 0:332983584a9c | 3 | * |
rgrover1 | 0:332983584a9c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 0:332983584a9c | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 0:332983584a9c | 6 | * You may obtain a copy of the License at |
rgrover1 | 0:332983584a9c | 7 | * |
rgrover1 | 0:332983584a9c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 0:332983584a9c | 9 | * |
rgrover1 | 0:332983584a9c | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 0:332983584a9c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 0:332983584a9c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 0:332983584a9c | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 0:332983584a9c | 14 | * limitations under the License. |
rgrover1 | 0:332983584a9c | 15 | */ |
rgrover1 | 0:332983584a9c | 16 | |
rgrover1 | 0:332983584a9c | 17 | #include "mbed.h" |
rgrover1 | 4:dd8231564124 | 18 | #include "BLE.h" |
rgrover1 | 0:332983584a9c | 19 | |
rgrover1 | 0:332983584a9c | 20 | BLEDevice ble; |
rgrover1 | 0:332983584a9c | 21 | DigitalOut led1(LED1); |
rgrover1 | 0:332983584a9c | 22 | |
rgrover1 | 0:332983584a9c | 23 | void periodicCallback(void) |
rgrover1 | 0:332983584a9c | 24 | { |
rgrover1 | 0:332983584a9c | 25 | led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */ |
rgrover1 | 0:332983584a9c | 26 | } |
rgrover1 | 0:332983584a9c | 27 | |
rgrover1 | 3:50a7d47912b2 | 28 | void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params) { |
rgrover1 | 3:50a7d47912b2 | 29 | |
rgrover1 | 0:332983584a9c | 30 | printf("Adv peerAddr: [%02x %02x %02x %02x %02x %02x] rssi %d, ScanResp: %u, AdvType: %u\r\n", |
rgrover1 | 3:50a7d47912b2 | 31 | params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0], |
rgrover1 | 3:50a7d47912b2 | 32 | params->rssi, params->isScanResponse, params->type); |
rgrover1 | 0:332983584a9c | 33 | #if DUMP_ADV_DATA |
rgrover1 | 3:50a7d47912b2 | 34 | for (unsigned index = 0; index < params->advertisingDataLen; index++) { |
rgrover1 | 3:50a7d47912b2 | 35 | printf("%02x ", params->advertisingData[index]); |
rgrover1 | 0:332983584a9c | 36 | } |
rgrover1 | 0:332983584a9c | 37 | printf("\r\n"); |
rgrover1 | 0:332983584a9c | 38 | #endif /* DUMP_ADV_DATA */ |
rgrover1 | 0:332983584a9c | 39 | } |
rgrover1 | 0:332983584a9c | 40 | |
rgrover1 | 0:332983584a9c | 41 | int main(void) |
rgrover1 | 0:332983584a9c | 42 | { |
rgrover1 | 0:332983584a9c | 43 | led1 = 1; |
rgrover1 | 0:332983584a9c | 44 | Ticker ticker; |
rgrover1 | 0:332983584a9c | 45 | ticker.attach(periodicCallback, 1); |
rgrover1 | 0:332983584a9c | 46 | |
rgrover1 | 0:332983584a9c | 47 | ble.init(); |
rgrover1 | 0:332983584a9c | 48 | |
rgrover1 | 0:332983584a9c | 49 | ble.setScanParams(500 /* scan interval */, 200 /* scan window */); |
rgrover1 | 0:332983584a9c | 50 | ble.startScan(advertisementCallback); |
rgrover1 | 0:332983584a9c | 51 | |
rgrover1 | 0:332983584a9c | 52 | while (true) { |
rgrover1 | 0:332983584a9c | 53 | ble.waitForEvent(); |
rgrover1 | 0:332983584a9c | 54 | } |
rgrover1 | 0:332983584a9c | 55 | } |