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 DnsQuery ESP8266Interface NetworkSocketAPI mbed nRF51822
Fork of BLE_TemperatureBeacon by
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "mbed.h" 00018 #include "toolchain.h" 00019 #include "ble/BLE.h" 00020 #include "HealthThermometerService.h" 00021 00022 BLE ble; 00023 00024 static Ticker ticker; 00025 static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE}; 00026 const static char DEVICE_NAME[] = "Tower Thermometer"; 00027 00028 extern float getTemp(); 00029 00030 extern void wifiInit(); 00031 extern void wifiSend(float temp); 00032 00033 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) 00034 { 00035 ble.gap().startAdvertising(); 00036 } 00037 00038 int main(void) 00039 { 00040 //wifi init 00041 wifiInit(); 00042 00043 //ble advertising 00044 /* 00045 ble.init(); 00046 ble.gap().onDisconnection(disconnectionCallback); 00047 HealthThermometerService thermometerService(ble, getTemp(), HealthThermometerService::LOCATION_EAR); 00048 00049 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); 00050 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); 00051 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_THERMOMETER); 00052 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); 00053 ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); 00054 ble.gap().setAdvertisingInterval(500); 00055 ble.gap().startAdvertising(); 00056 */ 00057 while (1) { 00058 float temp = getTemp(); 00059 00060 wifiSend(temp); 00061 //thermometerService.updateTemperature( temp ); 00062 00063 //ble.waitForEvent(); 00064 wait(3); 00065 } 00066 }
Generated on Sun Jul 17 2022 17:11:33 by
1.7.2
