added max-age and content-format

Fork of mbedConnectorInterface by Doug Anson

Committer:
ansond
Date:
Sat Apr 11 18:33:21 2015 +0000
Revision:
40:bb551b9f4522
Parent:
38:96d15287b6f9
Child:
41:fb12c88260ad
fixes to TickerResourceObserver... working now...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 38:96d15287b6f9 1 /**
ansond 38:96d15287b6f9 2 * @file TickerResourceObserver.cpp
ansond 38:96d15287b6f9 3 * @brief mbed CoAP DynamicResource Ticker-based observer (implementation)
ansond 38:96d15287b6f9 4 * @author Doug Anson/Chris Paola
ansond 38:96d15287b6f9 5 * @version 1.0
ansond 38:96d15287b6f9 6 * @see
ansond 38:96d15287b6f9 7 *
ansond 38:96d15287b6f9 8 * Copyright (c) 2014
ansond 38:96d15287b6f9 9 *
ansond 38:96d15287b6f9 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 38:96d15287b6f9 11 * you may not use this file except in compliance with the License.
ansond 38:96d15287b6f9 12 * You may obtain a copy of the License at
ansond 38:96d15287b6f9 13 *
ansond 38:96d15287b6f9 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 38:96d15287b6f9 15 *
ansond 38:96d15287b6f9 16 * Unless required by applicable law or agreed to in writing, software
ansond 38:96d15287b6f9 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 38:96d15287b6f9 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 38:96d15287b6f9 19 * See the License for the specific language governing permissions and
ansond 38:96d15287b6f9 20 * limitations under the License.
ansond 38:96d15287b6f9 21 */
ansond 38:96d15287b6f9 22
ansond 38:96d15287b6f9 23 #include "TickerResourceObserver.h"
ansond 38:96d15287b6f9 24
ansond 38:96d15287b6f9 25 // determines whether the mDS endpoint has been registered or not...
ansond 38:96d15287b6f9 26 extern "C" bool nsdl_endpoint_is_registered(void);
ansond 38:96d15287b6f9 27
ansond 38:96d15287b6f9 28 // constructor
ansond 40:bb551b9f4522 29 TickerResourceObserver::TickerResourceObserver(DynamicResource *resource,int sleep_time) :
ansond 40:bb551b9f4522 30 ResourceObserver(resource,(int)(sleep_time/1000)) {
ansond 40:bb551b9f4522 31 this->setObserving(false);
ansond 38:96d15287b6f9 32 }
ansond 38:96d15287b6f9 33
ansond 38:96d15287b6f9 34 // destructor
ansond 38:96d15287b6f9 35 TickerResourceObserver::~TickerResourceObserver() {
ansond 38:96d15287b6f9 36 this->stopObservation();
ansond 38:96d15287b6f9 37 }
ansond 38:96d15287b6f9 38
ansond 38:96d15287b6f9 39 // notifier
ansond 38:96d15287b6f9 40 void TickerResourceObserver::observationNotifier() {
ansond 40:bb551b9f4522 41 if (this->isObserving() == true && this->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
ansond 38:96d15287b6f9 42 this->getResource()->observe();
ansond 38:96d15287b6f9 43 }
ansond 38:96d15287b6f9 44 }
ansond 38:96d15287b6f9 45
ansond 38:96d15287b6f9 46 // begin observing...
ansond 38:96d15287b6f9 47 void TickerResourceObserver::beginObservation() {
ansond 40:bb551b9f4522 48 if (this->isObserving() == false) {
ansond 38:96d15287b6f9 49 this->m_ticker.attach(this,&TickerResourceObserver::observationNotifier,(float)this->getSleepTime());
ansond 40:bb551b9f4522 50 this->setObserving(true);
ansond 38:96d15287b6f9 51 }
ansond 38:96d15287b6f9 52 }
ansond 38:96d15287b6f9 53
ansond 38:96d15287b6f9 54 // begin observing...
ansond 38:96d15287b6f9 55 void TickerResourceObserver::stopObservation() {
ansond 40:bb551b9f4522 56 this->setObserving(false);
ansond 38:96d15287b6f9 57 }