This is the sample program that can see the decode result of barcode data on Watson IoT.
Dependencies: AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice
MinarResourceObserver.cpp
00001 /** 00002 * @file MinarResourceObserver.cpp 00003 * @brief mbed CoAP DynamicResource Minar-based observer (implementation) 00004 * @author Doug Anson/Chris Paola 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2014 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 */ 00022 00023 // class support 00024 #include "mbed-connector-interface/MinarResourceObserver.h" 00025 00026 #if defined(MCI_MINAR_SCHEDULER) 00027 00028 // constructor 00029 MinarResourceObserver::MinarResourceObserver(DynamicResource *resource,int sleep_time) : ResourceObserver(resource,sleep_time) { 00030 this->setObserving(false); 00031 00032 // DEBUG 00033 if (sleep_time > 0) { 00034 this->logger()->log("MinarResourceObserver being used for %s (sleep_time: %d ms)",resource->getFullName().c_str(),sleep_time); 00035 } 00036 else { 00037 this->logger()->log("MinarResourceObserver being used for %s",resource->getFullName().c_str()); 00038 } 00039 } 00040 00041 // destructor 00042 MinarResourceObserver::~MinarResourceObserver() { 00043 this->stopObservation(); 00044 } 00045 00046 // notifier 00047 void MinarResourceObserver::perform_observation() { 00048 if (this->isObserving() == true && this->getResource() != NULL && this->getResource()->isConnected() == true) { 00049 this->getResource()->observe(); 00050 } 00051 } 00052 00053 // begin observing... 00054 void MinarResourceObserver::beginObservation() { 00055 this->setObserving(true); 00056 minar::Scheduler::postCallback(this,&MinarResourceObserver::perform_observation).period(minar::milliseconds(this->getSleepTime())); 00057 } 00058 00059 // stop observing... 00060 void MinarResourceObserver::stopObservation() { 00061 this->setObserving(false); 00062 } 00063 00064 // halt the underlying observer mechanism 00065 void MinarResourceObserver::halt() { 00066 minar::Scheduler::stop(); 00067 } 00068 00069 #endif // MCI_MINAR_SCHEDULER
Generated on Tue Jul 12 2022 18:38:05 by 1.7.2