1 #include "protocols/client_server/MsgMoteIdList.h"
3 namespace remote
{ namespace protocols
{ namespace client_server
{
5 MsgMoteIdList::MsgMoteIdList() : moteIdList()
9 void MsgMoteIdList::operator = (const MsgMoteIdList
& o
)
11 moteIdList
= o
.moteIdList
;
14 uint32_t MsgMoteIdList::getLength()
16 // length and elements
17 return sizeof(uint16_t)+sizeof(uint32_t)*moteIdList
.size();
20 uint8_t* MsgMoteIdList::write(uint8_t* buffer
, uint32_t& buflen
)
25 count
= moteIdList
.size();
27 buffer
= writevalue(count
,buffer
,buflen
);
30 for ( i
= moteIdList
.begin(); i
!= moteIdList
.end(); i
++)
33 buffer
= writevalue(moteId
,buffer
,buflen
);
38 uint8_t* MsgMoteIdList::read(uint8_t* buffer
, uint32_t& buflen
)
44 buffer
= readvalue(count
,buffer
,buflen
);
46 for (i
=0; i
< count
; i
++)
48 buffer
= readvalue(moteId
,buffer
,buflen
);
49 moteIdList
.push_back(moteId
);
54 void MsgMoteIdList::print(FILE* s
)
58 count
= moteIdList
.size();
59 fprintf(s
,"MESSAGE MsgMoteIdList\n");
60 fprintf(s
,"%u elements:\n",count
);
63 for ( i
= moteIdList
.begin(); i
!= moteIdList
.end(); i
++)
66 fprintf(s
,"%u\n",moteId
);
70 void MsgMoteIdList::clear()
75 void MsgMoteIdList::addMoteId(dbkey_t p_moteId
)
77 moteIdList
.push_back(p_moteId
);
80 bool MsgMoteIdList::getNextMoteId(dbkey_t
&p_moteId
)
82 if (moteIdList
.empty()) return false;
85 p_moteId
= moteIdList
.front();
86 moteIdList
.pop_front();