Demo program of a simple BLE temperature gateway that scans for temperature broadcasts from beacons while simultaneously acting as a peripheral.
Dependencies: BLE_API mbed nRF51822
TMP_nrf51/TMP_nrf51.cpp@0:3aa044e110b8, 2015-10-05 (annotated)
- Committer:
- andresag
- Date:
- Mon Oct 05 12:59:40 2015 +0000
- Revision:
- 0:3aa044e110b8
Initial version of a simple BLE temperature gateway that scans temperature broadcasts while simultaneously acting as a peripheral.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andresag | 0:3aa044e110b8 | 1 | /* mbed Microcontroller Library |
andresag | 0:3aa044e110b8 | 2 | * Copyright (c) 2006-2015 ARM Limited |
andresag | 0:3aa044e110b8 | 3 | * |
andresag | 0:3aa044e110b8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
andresag | 0:3aa044e110b8 | 5 | * you may not use this file except in compliance with the License. |
andresag | 0:3aa044e110b8 | 6 | * You may obtain a copy of the License at |
andresag | 0:3aa044e110b8 | 7 | * |
andresag | 0:3aa044e110b8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
andresag | 0:3aa044e110b8 | 9 | * |
andresag | 0:3aa044e110b8 | 10 | * Unless required by applicable law or agreed to in writing, software |
andresag | 0:3aa044e110b8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
andresag | 0:3aa044e110b8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
andresag | 0:3aa044e110b8 | 13 | * See the License for the specific language governing permissions and |
andresag | 0:3aa044e110b8 | 14 | * limitations under the License. |
andresag | 0:3aa044e110b8 | 15 | */ |
andresag | 0:3aa044e110b8 | 16 | |
andresag | 0:3aa044e110b8 | 17 | #include "TMP_nrf51.h" |
andresag | 0:3aa044e110b8 | 18 | #include "nrf_soc.h" // for internal thermometer sensor |
andresag | 0:3aa044e110b8 | 19 | |
andresag | 0:3aa044e110b8 | 20 | /** |
andresag | 0:3aa044e110b8 | 21 | * @brief Get the temperature value. |
andresag | 0:3aa044e110b8 | 22 | * |
andresag | 0:3aa044e110b8 | 23 | * @return Die temperature in °C |
andresag | 0:3aa044e110b8 | 24 | */ |
andresag | 0:3aa044e110b8 | 25 | TMP_nrf51::TempSensorValue_t TMP_nrf51::get(void) |
andresag | 0:3aa044e110b8 | 26 | { |
andresag | 0:3aa044e110b8 | 27 | int32_t p_temp; |
andresag | 0:3aa044e110b8 | 28 | sd_temp_get(&p_temp); |
andresag | 0:3aa044e110b8 | 29 | |
andresag | 0:3aa044e110b8 | 30 | return ((TempSensorValue_t)p_temp * 0.25); /* 0.25 is temperature sensor resolution */ |
andresag | 0:3aa044e110b8 | 31 | } |