Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Light.cpp@3:8173336969c9, 2014-02-24 (annotated)
- Committer:
- ansond
- Date:
- Mon Feb 24 19:28:51 2014 +0000
- Revision:
- 3:8173336969c9
- Parent:
- 1:5d332fa199ce
- Child:
- 5:c1c4d511b589
fixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:4c9bfcb3e759 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:4c9bfcb3e759 | 2 | * |
ansond | 0:4c9bfcb3e759 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:4c9bfcb3e759 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:4c9bfcb3e759 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:4c9bfcb3e759 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:4c9bfcb3e759 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:4c9bfcb3e759 | 8 | * |
ansond | 0:4c9bfcb3e759 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:4c9bfcb3e759 | 10 | * substantial portions of the Software. |
ansond | 0:4c9bfcb3e759 | 11 | * |
ansond | 0:4c9bfcb3e759 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:4c9bfcb3e759 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:4c9bfcb3e759 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:4c9bfcb3e759 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:4c9bfcb3e759 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:4c9bfcb3e759 | 17 | */ |
ansond | 0:4c9bfcb3e759 | 18 | |
ansond | 0:4c9bfcb3e759 | 19 | #include "Light.h" |
ansond | 1:5d332fa199ce | 20 | #include "MBEDEndpoint.h" |
ansond | 0:4c9bfcb3e759 | 21 | |
ansond | 0:4c9bfcb3e759 | 22 | // default constructor |
ansond | 0:4c9bfcb3e759 | 23 | Light::Light(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) { |
ansond | 0:4c9bfcb3e759 | 24 | this->m_error_handler = error_handler; |
ansond | 1:5d332fa199ce | 25 | this->m_resources = ((MBEDEndpoint *)endpoint)->initResourceFactory(); |
ansond | 0:4c9bfcb3e759 | 26 | this->m_endpoint = endpoint; |
ansond | 0:4c9bfcb3e759 | 27 | for(int i=0;i<NUM_TRANSPORTS;++i) { |
ansond | 0:4c9bfcb3e759 | 28 | this->m_transports[i] = transports[i]; |
ansond | 0:4c9bfcb3e759 | 29 | this->m_transports[i]->setEndpoint(this); |
ansond | 0:4c9bfcb3e759 | 30 | } |
ansond | 0:4c9bfcb3e759 | 31 | sprintf(this->m_name,LIGHT_NAME,instance); |
ansond | 3:8173336969c9 | 32 | this->resources()->createResources(); |
ansond | 0:4c9bfcb3e759 | 33 | |
ansond | 0:4c9bfcb3e759 | 34 | // DEBUG |
ansond | 0:4c9bfcb3e759 | 35 | this->logger()->log("Light name:%s\n", this->getName()); |
ansond | 0:4c9bfcb3e759 | 36 | } |
ansond | 0:4c9bfcb3e759 | 37 | |
ansond | 0:4c9bfcb3e759 | 38 | // default destructor |
ansond | 0:4c9bfcb3e759 | 39 | Light::~Light() { |
ansond | 0:4c9bfcb3e759 | 40 | |
ansond | 0:4c9bfcb3e759 | 41 | } |
ansond | 0:4c9bfcb3e759 | 42 | |
ansond | 0:4c9bfcb3e759 | 43 | // get the requested transport |
ansond | 0:4c9bfcb3e759 | 44 | Transport *Light::getTransport(int index) { return this->m_transports[index]; } |
ansond | 0:4c9bfcb3e759 | 45 | |
ansond | 0:4c9bfcb3e759 | 46 | // get the light name |
ansond | 0:4c9bfcb3e759 | 47 | char *Light::getName() { return this->m_name; } |
ansond | 1:5d332fa199ce | 48 | |
ansond | 0:4c9bfcb3e759 | 49 | // get the error handler |
ansond | 0:4c9bfcb3e759 | 50 | ErrorHandler *Light::logger() { return this->m_error_handler; } |
ansond | 0:4c9bfcb3e759 | 51 | |
ansond | 1:5d332fa199ce | 52 | // get the resources factory |
ansond | 1:5d332fa199ce | 53 | ResourceFactory *Light::resources() { return this->m_resources; } |
ansond | 1:5d332fa199ce | 54 | |
ansond | 0:4c9bfcb3e759 | 55 | |
ansond | 0:4c9bfcb3e759 | 56 |