Beispiel #1
0
/*=====================================
        Class Topics
 ======================================*/
Topics::Topics(){
	Topic* tp = new Topic(string(MQTTSN_TOPIC_PREDEFINED_TIME));
	tp->setTopicId(MQTTSN_TOPICID_PREDEFINED_TIME);
	_topics.push_back(tp);
	_cnt = 1;
	_nextTopicId = MQTTSN_TOPICID_NORMAL;
}
Beispiel #2
0
bool Topics::setTopicId(MQString* topic, uint16_t id){
    Topic* p = getTopic(topic);
    if ( p != NULL) {
        p->setTopicId(id);
        return true;
    }else{
        return false;
    }
}
Beispiel #3
0
uint16_t Topics::createTopic(string* topic){
    if (!getTopic(topic)){
        if ( _cnt < MAX_TOPIC_COUNT){
        	Topic* tp = new Topic();
        	tp->setTopicName(*topic);
        	if(tp->getTopicLength() == 2){
        		uint16_t id = getUint16((uint8_t*)tp->getTopicName());
        		tp->setTopicId(id);
        	}else{
        		tp->setTopicId(getNextTopicId());
        	}
        	_topics.push_back(tp);
        	_cnt++;
        	return _nextTopicId;
        }else{
        	return 0;
        }
    }else{
    	return getTopicId(topic);
    }
}