Run on TY51822r3 board with ACC sensor (LIS3DH or BMC050)

Dependencies:   BLE_API LIS3DH mbed nRF51822 BMC050 nRF51_LowPwr nRF51_Vdd

Fork of BLE_EddystoneBeacon_Service by Bluetooth Low Energy

main.cpp

Committer:
mbedAustin
Date:
2015-08-11
Revision:
31:bdd03742096a
Parent:
30:6c2db8bf5b17
Child:
32:41840b78597e

File content as of revision 31:bdd03742096a:

/* 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/BLE.h"
#include "ble/services/EddystoneService.h"

BLE ble;
uint8_t UIDnamespace[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA}; // 10Bytes for Namespace UUID
uint8_t UIDinstance[]  = {0xbb,0xcc,0xdd,0xee,0xff,0x00}; // 6Bytes for Instance UUID
char Url[] = "http://www.mbed.org";
int8_t txPower = -40;
uint16_t beaconPeriodus = 1000;

//Callbacks for temperature / battery updates
Ticker tlmBattery;
Ticker tlmTemperature;
int battery = 0;
int temp = 0;

// Add Eddystone service to BLE device, can pass NULL for UID and URL parameters to disable those frames
EddystoneService eddyBeacon(ble, beaconPeriodus, txPower ,UIDnamespace, UIDinstance, Url, sizeof(Url));

// Optional Function to update Eddystone beacon TLM frame battery voltage
void tlmBatteryCallback(void){
    eddyBeacon.updateTlmBatteryVoltage(battery++);
}

// Optional Function to update Eddystone beacon TLM frame temperature
void tlmTemperatureCallback(void){
    eddyBeacon.updateTlmBeaconTemp(temp++);
}

int main(void)
{
    printf("Starting Example\r\n");
    tlmTemperature.attach(tlmTemperatureCallback,2.0f);
    tlmBattery.attach(tlmBatteryCallback, 1.0f);
    printf("Running...\r\n");
    while (true) {
        ble.waitForEvent();
    }
}