Jack Hansdampf / mbed-mqtt-GSOE1

Dependents:   ESP8266MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MQTTSNGWQoSm1Proxy.cpp Source File

MQTTSNGWQoSm1Proxy.cpp

00001 /**************************************************************************************
00002  * Copyright (c) 2018, Tomoaki Yamaguchi
00003  *
00004  * All rights reserved. This program and the accompanying materials
00005  * are made available under the terms of the Eclipse Public License v1.0
00006  * and Eclipse Distribution License v1.0 which accompany this distribution.
00007  *
00008  * The Eclipse Public License is available at
00009  *    http://www.eclipse.org/legal/epl-v10.html
00010  * and the Eclipse Distribution License is available at
00011  *   http://www.eclipse.org/org/documents/edl-v10.php.
00012  *
00013  * Contributors:
00014  *    Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
00015  **************************************************************************************/
00016 
00017 #include "MQTTSNGWQoSm1Proxy.h"
00018 #include "MQTTSNGateway.h"
00019 #include "SensorNetwork.h"
00020 #include "MQTTSNGWClientList.h"
00021 #include <string>
00022 #include <string.h>
00023 
00024 
00025 using namespace MQTTSNGW;
00026 
00027 /*=====================================
00028      Class QoSm1Proxy
00029  =====================================*/
00030 QoSm1Proxy:: QoSm1Proxy(Gateway* gw) : Adapter(gw)
00031 {
00032     _gateway = gw;
00033 }
00034 
00035 QoSm1Proxy::~QoSm1Proxy(void)
00036 {
00037 
00038 }
00039 
00040 
00041 void QoSm1Proxy::initialize(void)
00042 {
00043     char param[MQTTSNGW_PARAM_MAX];
00044 
00045     if ( _gateway->hasSecureConnection() )
00046     {
00047         _isSecure = true;
00048     }
00049 
00050     if (_gateway->getParam("QoS-1", param) == 0 )
00051     {
00052         if (strcasecmp(param, "YES") == 0 )
00053         {
00054             /*  Create QoS-1 Clients */
00055             _gateway->getClientList()->setClientList(QOSM1PROXY_TYPE);
00056 
00057             /* initialize Adapter */
00058             string name = string(_gateway->getGWParams()->gatewayName) + "QoS-1";
00059             setup(name.c_str(), Atype_QoSm1Proxy);
00060            _isActive = true;
00061         }
00062     }
00063 }
00064 
00065 
00066 bool QoSm1Proxy::isActive(void)
00067 {
00068     return _isActive;
00069 }
00070