bool isEmptyResourcePresence() const;
const std::string getAddress() const;
- DEVICE_STATE getDeviceState() const;
+ DEVICE_STATE getDeviceState() const noexcept;
+
private:
std::list<ResourcePresence * > resourcePresenceList;
void changeAllPresenceMode(BROKER_MODE mode);
void subscribeCB(OCStackResult ret,const unsigned int seq, const std::string& Hostaddress);
void timeOutCB(TimerID id);
+
+ void setDeviceState(DEVICE_STATE);
};
} // namespace Service
} // namespace OIC
{
DevicePresence::DevicePresence()
{
- state = DEVICE_STATE::REQUESTED;
+ setDeviceState(DEVICE_STATE::REQUESTED);
presenceTimerHandle = 0;
isRunningTimeOut = false;
presenceTimerHandle
= presenceTimer.post(BROKER_DEVICE_PRESENCE_TIMEROUT, pTimeoutCB);
}
- DEVICE_STATE DevicePresence::getDeviceState() const
+
+ DEVICE_STATE DevicePresence::getDeviceState() const noexcept
{
- int ret=state;
- return (DEVICE_STATE)ret;
+ return static_cast< DEVICE_STATE >(state.load());
}
+
+ void DevicePresence::setDeviceState(DEVICE_STATE newState)
+ {
+ state = static_cast< int >(newState);
+ }
+
const std::string DevicePresence::getAddress() const
{
OC_LOG_V(DEBUG, BROKER_TAG, "getAddress()");
case OC_STACK_CONTINUE:
{
OC_LOG_V(DEBUG, BROKER_TAG, "SEQ# %d",seq);
- state = DEVICE_STATE::ALIVE;
+ setDeviceState(DEVICE_STATE::ALIVE);
OC_LOG_V(DEBUG, BROKER_TAG, "device state : %d",
(int)getDeviceState());
changeAllPresenceMode(BROKER_MODE::DEVICE_PRESENCE_MODE);
case OC_STACK_PRESENCE_TIMEOUT:
case OC_STACK_PRESENCE_DO_NOT_HANDLE:
{
- state = DEVICE_STATE::LOST_SIGNAL;
+ setDeviceState(DEVICE_STATE::LOST_SIGNAL);
changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE);
break;
}
default:
{
OC_LOG_V(DEBUG, BROKER_TAG, "Presence Lost Signal because unknown type");
- state = DEVICE_STATE::LOST_SIGNAL;
+ setDeviceState(DEVICE_STATE::LOST_SIGNAL);
changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE);
break;
}
OC_LOG_V(DEBUG, BROKER_TAG,
"Timeout execution. will be discard after receiving cb message");
- state = DEVICE_STATE::LOST_SIGNAL;
+ setDeviceState(DEVICE_STATE::LOST_SIGNAL);
changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE);
isRunningTimeOut = false;