use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Tue Jun 14 19:29:30 2016 +0000
Revision:
33:1d0b855df5a5
Parent:
0:1f1f55e73248
Child:
51:91fc5f5880fe
updated and unified headers

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 33:1d0b855df5a5 1 /**
ansond 33:1d0b855df5a5 2 * @file Location.cpp
ansond 33:1d0b855df5a5 3 * @brief mbed CoAP Endpoint Location base class
ansond 33:1d0b855df5a5 4 * @author Doug Anson/Chris Paola
ansond 33:1d0b855df5a5 5 * @version 1.0
ansond 33:1d0b855df5a5 6 * @see
ansond 33:1d0b855df5a5 7 *
ansond 33:1d0b855df5a5 8 * Copyright (c) 2014
ansond 33:1d0b855df5a5 9 *
ansond 33:1d0b855df5a5 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 33:1d0b855df5a5 11 * you may not use this file except in compliance with the License.
ansond 33:1d0b855df5a5 12 * You may obtain a copy of the License at
ansond 33:1d0b855df5a5 13 *
ansond 33:1d0b855df5a5 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 33:1d0b855df5a5 15 *
ansond 33:1d0b855df5a5 16 * Unless required by applicable law or agreed to in writing, software
ansond 33:1d0b855df5a5 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 33:1d0b855df5a5 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 33:1d0b855df5a5 19 * See the License for the specific language governing permissions and
ansond 33:1d0b855df5a5 20 * limitations under the License.
ansond 33:1d0b855df5a5 21 */
ansond 33:1d0b855df5a5 22
ansond 33:1d0b855df5a5 23 // Class support
ansond 33:1d0b855df5a5 24 #include "mbed-connector-interface/Location.h"
ansond 33:1d0b855df5a5 25
ansond 33:1d0b855df5a5 26 namespace Connector {
ansond 33:1d0b855df5a5 27
ansond 33:1d0b855df5a5 28 // Constructor
ansond 33:1d0b855df5a5 29 Location::Location(const RawSerial *pc) {
ansond 33:1d0b855df5a5 30 this->m_pc = (RawSerial *)pc;
ansond 33:1d0b855df5a5 31 this->initBuffers();
ansond 33:1d0b855df5a5 32 }
ansond 0:1f1f55e73248 33
ansond 33:1d0b855df5a5 34 // Copy Constructor
ansond 33:1d0b855df5a5 35 Location::Location(const Location &location) {
ansond 33:1d0b855df5a5 36 this->m_pc = location.m_pc;
ansond 33:1d0b855df5a5 37 memcpy(this->m_latitude,location.m_latitude,LOCATION_COORDINATE_LENGTH+1);
ansond 33:1d0b855df5a5 38 memcpy(this->m_longitude,location.m_longitude,LOCATION_COORDINATE_LENGTH+1);
ansond 33:1d0b855df5a5 39 memcpy(this->m_msl_altitude_m,location.m_msl_altitude_m,LOCATION_MSL_ALT_LENGTH+1);
ansond 33:1d0b855df5a5 40 memcpy(this->m_speed,location.m_speed,LOCATION_SPEED_LENGTH+1);
ansond 33:1d0b855df5a5 41 }
ansond 33:1d0b855df5a5 42
ansond 33:1d0b855df5a5 43 // Destructor
ansond 33:1d0b855df5a5 44 Location::~Location() {
ansond 33:1d0b855df5a5 45 }
ansond 33:1d0b855df5a5 46
ansond 33:1d0b855df5a5 47 // init the buffers
ansond 33:1d0b855df5a5 48 void Location::initBuffers() {
ansond 33:1d0b855df5a5 49 memset(this->m_latitude,0,LOCATION_COORDINATE_LENGTH+1);
ansond 33:1d0b855df5a5 50 memset(this->m_longitude,0,LOCATION_COORDINATE_LENGTH+1);
ansond 33:1d0b855df5a5 51 memset(this->m_msl_altitude_m,0,LOCATION_MSL_ALT_LENGTH+1);
ansond 33:1d0b855df5a5 52 memset(this->m_speed,0,LOCATION_SPEED_LENGTH+1);
ansond 33:1d0b855df5a5 53 }
ansond 33:1d0b855df5a5 54
ansond 33:1d0b855df5a5 55 // get the latitude
ansond 33:1d0b855df5a5 56 char *Location::getLatitude() {
ansond 33:1d0b855df5a5 57 return this->m_latitude;
ansond 33:1d0b855df5a5 58 }
ansond 33:1d0b855df5a5 59
ansond 33:1d0b855df5a5 60 // get the longitude
ansond 33:1d0b855df5a5 61 char *Location::getLongitude() {
ansond 33:1d0b855df5a5 62 return this->m_longitude;
ansond 33:1d0b855df5a5 63 }
ansond 33:1d0b855df5a5 64
ansond 33:1d0b855df5a5 65 // get the MSL Altitude
ansond 33:1d0b855df5a5 66 char *Location::getMSLAltitude() {
ansond 33:1d0b855df5a5 67 return this->m_msl_altitude_m;
ansond 33:1d0b855df5a5 68 }
ansond 33:1d0b855df5a5 69
ansond 33:1d0b855df5a5 70 // get the Speed
ansond 33:1d0b855df5a5 71 char *Location::getSpeed() {
ansond 33:1d0b855df5a5 72 return this->m_speed;
ansond 33:1d0b855df5a5 73 }
ansond 33:1d0b855df5a5 74
ansond 33:1d0b855df5a5 75 };
ansond 33:1d0b855df5a5 76