help_vars.Add(BoolVariable('WITH_RA', 'Build with Remote Access module', False))
help_vars.Add(BoolVariable('WITH_TCP', 'Build with TCP adapter', False))
+help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER']))
help_vars.Add(EnumVariable('WITH_RD', 'Build including Resource Directory', '0', allowed_values=('0', '1')))
help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including Cloud client sample', False))
with_ra = env.get('WITH_RA')
with_ra_ibb = env.get('WITH_RA_IBB')
with_tcp = env.get('WITH_TCP')
+with_mq = env.get('WITH_MQ')
# As in the source code, it includes arduino Time library (C++)
# It requires compile the .c with g++
if target_os == 'arduino':
'security/provisioning/include',
])
+if 'SUB' in with_mq:
+ liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+if 'PUB' in with_mq:
+ liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+if 'BROKER' in with_mq:
+ liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+
if target_os not in ['arduino', 'windows']:
liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
build_sample = env.get('BUILD_SAMPLE')
with_ra = env.get('WITH_RA')
with_tcp = env.get('WITH_TCP')
+with_mq = env.get('WITH_MQ')
print "Given Transport is %s" % transport
print "Given OS is %s" % target_os
print "BUILD_SAMPLE is %s" % build_sample
+print "MQ flag is %s" % with_mq
targets_disallow_multitransport = ['arduino']
else:
env.AppendUnique(CPPDEFINES = ['NO_NFC_ADAPTER'])
+if 'SUB' in with_mq:
+ env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+ print "MQ SUB support"
+
+if 'PUB' in with_mq:
+ env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+ print "MQ PUB support"
+
+if 'BROKER' in with_mq:
+ env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+ print "MQ Broker support"
+
env.SConscript('./src/SConscript')
/** When this bit is set, the resource is allowed to be discovered only
* if discovery request contains an explicit querystring.
* Ex: GET /oic/res?rt=oic.sec.acl */
- OC_EXPLICIT_DISCOVERABLE = (1 << 5)
+ OC_EXPLICIT_DISCOVERABLE = (1 << 5),
+
+#ifdef WITH_MQ
+ /** When this bit is set, the resource is allowed to be published */
+ OC_MQ_PUBLISHER = (1 << 6),
+#endif
+
+#ifdef MQ_BROKER
+ /** When this bit is set, the resource is allowed to be notified as MQ broker.*/
+ OC_MQ_BROKER = (1 << 7),
+#endif
} OCResourceProperty;
/**
}
}
- pl->bitmap = res->resourceProperties & (OC_OBSERVABLE | OC_DISCOVERABLE);
+ pl->bitmap = res->resourceProperties & (OC_OBSERVABLE | OC_DISCOVERABLE
+#ifdef MQ_PUBLISHER
+ | OC_MQ_PUBLISHER
+#endif
+ );
pl->secure = (res->resourceProperties & OC_SECURE) != 0;
pl->port = securePort;
#ifdef TCP_ADAPTER
resourceInterfaceName = OC_RSRVD_INTERFACE_DEFAULT;
}
+#ifdef MQ_PUBLISHER
+ resourceProperties = resourceProperties | OC_MQ_PUBLISHER;
+#endif
// Make sure resourceProperties bitmask has allowed properties specified
if (resourceProperties
> (OC_ACTIVE | OC_DISCOVERABLE | OC_OBSERVABLE | OC_SLOW | OC_SECURE |
- OC_EXPLICIT_DISCOVERABLE))
+ OC_EXPLICIT_DISCOVERABLE
+#ifdef MQ_PUBLISHER
+ | OC_MQ_PUBLISHER
+#endif
+#ifdef MQ_BROKER
+ | OC_MQ_BROKER
+#endif
+ ))
{
OIC_LOG(ERROR, TAG, "Invalid property");
return OC_STACK_INVALID_PARAM;
m_resourceId(std::move(o.m_resourceId)),
m_devAddr(std::move(o.m_devAddr)),
m_useHostString(o.m_useHostString),
- m_isObservable(o.m_isObservable),
+ m_property(o.m_property),
m_isCollection(o.m_isCollection),
m_resourceTypes(std::move(o.m_resourceTypes)),
m_interfaces(std::move(o.m_interfaces)),
*/
bool isObservable() const;
+#ifdef WITH_MQ
+ /**
+ * Function to provide ability to check if this resource is publisher or not
+ * @return bool true indicates resource is publisher; false indicates resource is
+ * not publisher.
+ */
+ bool isPublish() const;
+#endif
+
/**
* Function to get the list of resource types
* @return vector of resource types
OCResourceIdentifier m_resourceId;
OCDevAddr m_devAddr;
bool m_useHostString;
- bool m_isObservable;
bool m_isCollection;
+ uint8_t m_property;
std::vector<std::string> m_resourceTypes;
std::vector<std::string> m_interfaces;
std::vector<std::string> m_children;
private:
OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
const OCDevAddr& devAddr, const std::string& uri,
- const std::string& serverId, bool observable,
+ const std::string& serverId, uint8_t property,
const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces);
OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
const std::string& host, const std::string& uri,
const std::string& serverId,
- OCConnectivityType connectivityType, bool observable,
+ OCConnectivityType connectivityType, uint8_t property,
const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces);
};
new OC::OCResource(m_clientWrapper, rdPubAddr,
std::string(res->uri),
std::string(payload->sid),
- (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
+ res->bitmap,
StringLLToVector(res->types),
StringLLToVector(res->interfaces)
)));
new OC::OCResource(m_clientWrapper, m_devAddr,
std::string(res->uri),
std::string(payload->sid),
- (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
+ res->bitmap,
StringLLToVector(res->types),
StringLLToVector(res->interfaces)
)));
new OC::OCResource(m_clientWrapper, tcpDevAddr,
std::string(res->uri),
std::string(payload->sid),
- (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
+ res->bitmap,
StringLLToVector(res->types),
StringLLToVector(res->interfaces)
)));
return std::shared_ptr<OCResource>();
}
+ uint8_t resourceProperty = 0;
+ if (isObservable)
+ {
+ resourceProperty = (resourceProperty | OC_OBSERVABLE);
+ }
return std::shared_ptr<OCResource>(new OCResource(m_client,
host,
uri, "", connectivityType,
- isObservable,
+ resourceProperty,
resourceTypes,
interfaces));
}
OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
const OCDevAddr& devAddr, const std::string& uri,
- const std::string& serverId, bool observable,
+ const std::string& serverId, uint8_t property,
const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces)
: m_clientWrapper(clientWrapper), m_uri(uri),
m_resourceId(serverId, m_uri), m_devAddr(devAddr),
- m_isObservable(observable), m_isCollection(false),
+ m_property(property), m_isCollection(false),
m_resourceTypes(resourceTypes), m_interfaces(interfaces),
m_observeHandle(nullptr)
{
OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
const std::string& host, const std::string& uri,
const std::string& serverId,
- OCConnectivityType connectivityType, bool observable,
+ OCConnectivityType connectivityType, uint8_t property,
const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces)
: m_clientWrapper(clientWrapper), m_uri(uri),
m_resourceId(serverId, m_uri),
- m_isObservable(observable), m_isCollection(false),
+ m_property(property), m_isCollection(false),
m_resourceTypes(resourceTypes), m_interfaces(interfaces),
m_observeHandle(nullptr)
{
bool OCResource::isObservable() const
{
- return m_isObservable;
+ return (m_property & OC_OBSERVABLE) == OC_OBSERVABLE;
}
+#ifdef WITH_MQ
+bool OCResource::isPublish() const
+{
+ return (m_property & OC_MQ_PUBLISHER) == OC_MQ_PUBLISHER;
+}
+#endif
+
std::vector<std::string> OCResource::getResourceTypes() const
{
return m_resourceTypes;