Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of MEDRON_SNIFFER_ABCD-KIMLIKLI-OLANLARI-TARAMA-YAPAR_30062016 by
main.cpp
- Committer:
- sunsmile2015
- Date:
- 2015-07-15
- Revision:
- 6:850f44146c9f
- Parent:
- 5:103717ce54e5
- Child:
- 7:91324daa3bfa
File content as of revision 6:850f44146c9f:
/* mbed Microcontroller Library
* Copyright (c) 2006-2015 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mbed.h"
#include "BLE.h"
BLE ble;
DigitalOut led1(LED1);
void periodicCallback(void)
{
led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
}
void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params)
{
if((params->advertisingData[9] == 0xFE) && (params->advertisingData[10] == 0xFE)) {
float tempVal = 0;
printf("Adv peerAddr: [%02x %02x %02x %02x %02x %02x] rssi %d, ScanResp: %u, AdvType: %u\r\n",
params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0],
params->rssi, params->isScanResponse, params->type);
for (unsigned index = 0; index < params->advertisingDataLen; index++) {
printf("%02x ", params->advertisingData[index]);
}
memcpy(&tempVal, ¶ms->advertisingData[11], 4); /* temperature value */
printf("temp is %f\r\n", tempVal);
}
}
int main(void)
{
led1 = 1;
Ticker ticker;
ticker.attach(periodicCallback, 1);
ble.init();
ble.gap().setScanParams(1800 /* scan interval */, 1500 /* scan window */);
ble.gap().startScan(advertisementCallback);
while (true) {
ble.waitForEvent();
}
}
