UpdatedDecryp
Dependencies: BahlDecrypModified CyaSSL mbed nRF51822
Fork of Decryptulator by
main.cpp@6:850f44146c9f, 2015-07-15 (annotated)
- Committer:
- sunsmile2015
- Date:
- Wed Jul 15 02:53:12 2015 +0000
- Revision:
- 6:850f44146c9f
- Parent:
- 5:103717ce54e5
- Child:
- 7:91324daa3bfa
publish to my account
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 | 5:103717ce54e5 | 20 | BLE 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 | |
sunsmile2015 | 6:850f44146c9f | 28 | void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params) |
sunsmile2015 | 6:850f44146c9f | 29 | { |
sunsmile2015 | 6:850f44146c9f | 30 | if((params->advertisingData[9] == 0xFE) && (params->advertisingData[10] == 0xFE)) { |
sunsmile2015 | 6:850f44146c9f | 31 | float tempVal = 0; |
sunsmile2015 | 6:850f44146c9f | 32 | printf("Adv peerAddr: [%02x %02x %02x %02x %02x %02x] rssi %d, ScanResp: %u, AdvType: %u\r\n", |
sunsmile2015 | 6:850f44146c9f | 33 | params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0], |
sunsmile2015 | 6:850f44146c9f | 34 | params->rssi, params->isScanResponse, params->type); |
sunsmile2015 | 6:850f44146c9f | 35 | |
sunsmile2015 | 6:850f44146c9f | 36 | for (unsigned index = 0; index < params->advertisingDataLen; index++) { |
sunsmile2015 | 6:850f44146c9f | 37 | printf("%02x ", params->advertisingData[index]); |
sunsmile2015 | 6:850f44146c9f | 38 | } |
sunsmile2015 | 6:850f44146c9f | 39 | |
sunsmile2015 | 6:850f44146c9f | 40 | memcpy(&tempVal, ¶ms->advertisingData[11], 4); /* temperature value */ |
sunsmile2015 | 6:850f44146c9f | 41 | printf("temp is %f\r\n", tempVal); |
rgrover1 | 3:50a7d47912b2 | 42 | |
rgrover1 | 0:332983584a9c | 43 | } |
rgrover1 | 0:332983584a9c | 44 | } |
rgrover1 | 0:332983584a9c | 45 | |
rgrover1 | 0:332983584a9c | 46 | int main(void) |
rgrover1 | 0:332983584a9c | 47 | { |
rgrover1 | 0:332983584a9c | 48 | led1 = 1; |
rgrover1 | 0:332983584a9c | 49 | Ticker ticker; |
rgrover1 | 0:332983584a9c | 50 | ticker.attach(periodicCallback, 1); |
rgrover1 | 0:332983584a9c | 51 | |
rgrover1 | 0:332983584a9c | 52 | ble.init(); |
rgrover1 | 0:332983584a9c | 53 | |
sunsmile2015 | 6:850f44146c9f | 54 | ble.gap().setScanParams(1800 /* scan interval */, 1500 /* scan window */); |
rgrover1 | 5:103717ce54e5 | 55 | ble.gap().startScan(advertisementCallback); |
rgrover1 | 0:332983584a9c | 56 | |
rgrover1 | 0:332983584a9c | 57 | while (true) { |
rgrover1 | 0:332983584a9c | 58 | ble.waitForEvent(); |
rgrover1 | 0:332983584a9c | 59 | } |
rgrover1 | 0:332983584a9c | 60 | } |