Dreamforce 2015 BLE-based mDS HeartRate Monitor Endpoint

Dependencies:   GroveEarbudSensor mbed mbedConnectorInterface mbedEndpointNetwork_BLE

Committer:
ansond
Date:
Sat Jul 25 20:42:45 2015 +0000
Revision:
42:9741365cff35
Child:
47:5e57fdac6765
updated and added BLE Location

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 42:9741365cff35 1 /**
ansond 42:9741365cff35 2 * @file LocationResource.h
ansond 42:9741365cff35 3 * @brief mbed CoAP Endpoint Location resource supporting CoAP GET
ansond 42:9741365cff35 4 * @author Doug Anson
ansond 42:9741365cff35 5 * @version 1.0
ansond 42:9741365cff35 6 * @see
ansond 42:9741365cff35 7 *
ansond 42:9741365cff35 8 * Copyright (c) 2014
ansond 42:9741365cff35 9 *
ansond 42:9741365cff35 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 42:9741365cff35 11 * you may not use this file except in compliance with the License.
ansond 42:9741365cff35 12 * You may obtain a copy of the License at
ansond 42:9741365cff35 13 *
ansond 42:9741365cff35 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 42:9741365cff35 15 *
ansond 42:9741365cff35 16 * Unless required by applicable law or agreed to in writing, software
ansond 42:9741365cff35 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 42:9741365cff35 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 42:9741365cff35 19 * See the License for the specific language governing permissions and
ansond 42:9741365cff35 20 * limitations under the License.
ansond 42:9741365cff35 21 */
ansond 42:9741365cff35 22
ansond 42:9741365cff35 23 #ifndef __LOCATION_RESOURCE_H__
ansond 42:9741365cff35 24 #define __LOCATION_RESOURCE_H__
ansond 42:9741365cff35 25
ansond 42:9741365cff35 26 // Base class
ansond 42:9741365cff35 27 #include "DynamicResource.h"
ansond 42:9741365cff35 28
ansond 42:9741365cff35 29 // our Location source
ansond 42:9741365cff35 30 #include "BLELocation.h"
ansond 42:9741365cff35 31 extern RawSerial pc; // main.cpp
ansond 42:9741365cff35 32 BLELocation _ble_location(&pc); // BLE Location from the UART Proxy application
ansond 42:9741365cff35 33
ansond 42:9741365cff35 34 // Maximum Location JSON Length : {"latitude":XXX.YYYYYY, "longitude":XXX.YYYYYY, "msl":XXXXXX, "speed":XXXXXX}
ansond 42:9741365cff35 35 #define LOCATION_JSON_LENGTH 96
ansond 42:9741365cff35 36
ansond 42:9741365cff35 37 /** LocationResource class
ansond 42:9741365cff35 38 */
ansond 42:9741365cff35 39 class LocationResource : public DynamicResource
ansond 42:9741365cff35 40 {
ansond 42:9741365cff35 41 public:
ansond 42:9741365cff35 42 /**
ansond 42:9741365cff35 43 Default constructor
ansond 42:9741365cff35 44 @param logger input logger instance for this resource
ansond 42:9741365cff35 45 @param name input the Location resource name
ansond 42:9741365cff35 46 @param observable input the resource is Observable (default: FALSE)
ansond 42:9741365cff35 47 */
ansond 42:9741365cff35 48 LocationResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"Location",SN_GRS_GET_ALLOWED,observable) {
ansond 42:9741365cff35 49 }
ansond 42:9741365cff35 50
ansond 42:9741365cff35 51 /**
ansond 42:9741365cff35 52 Get the value of the Location sensor
ansond 42:9741365cff35 53 @returns string containing the temperature sensor value
ansond 42:9741365cff35 54 */
ansond 42:9741365cff35 55 virtual string get() {
ansond 42:9741365cff35 56 _ble_location.updateLocation();
ansond 42:9741365cff35 57 char json[LOCATION_JSON_LENGTH+1];
ansond 42:9741365cff35 58 memset(json,0,LOCATION_JSON_LENGTH+1);
ansond 42:9741365cff35 59 sprintf(json,"{\"latitude\":%s,\"longitude\":%s,\"msl\":%s,\"speed\":%s}",
ansond 42:9741365cff35 60 _ble_location.getLatitude(),
ansond 42:9741365cff35 61 _ble_location.getLongitude(),
ansond 42:9741365cff35 62 _ble_location.getMSLAltitude(),
ansond 42:9741365cff35 63 _ble_location.getSpeed());
ansond 42:9741365cff35 64 return string(json);
ansond 42:9741365cff35 65 }
ansond 42:9741365cff35 66 };
ansond 42:9741365cff35 67
ansond 42:9741365cff35 68 #endif // __LOCATION_RESOURCE_H__