C arrays are actually not supported.  The stack uses vectors of the
type.

So, you could do:

std::vector<int> m_temp;
m_temp.resize(2);
m_temp[0] = 0; m_temp[1] = 1;
m_myRep.setValue("temp", m_temp);


On Wed, 2015-11-18 at 02:28 +0000, ??? wrote:
> Hi. All,
> 
>  
> 
> I'm currently implmenting a resource server which has an array type
> attribute in a resource. But, I've encountered some troubles when
> retrieving/updating the attribute.
> 
>  
> 
> 1. In case of setting the attribute value in OCRepresentation object.
> 
>  - Using setValue() in OCRepresentation object, I'm trying to set a
> value of array type but it doesn't work well.
> 
>    Below is the code I used.
> 
>  
> 
>  int m_temp[2];
> 
>  m_temp[0] = 0; m_temp[1] = 1;
> 
>  m_myRep.setValue("temp", m_temp);
> 
>  
> 
>   It does not give me an error in compilation, but when I capture a
> packet with Wireshark, I confirm that the values (i.e. 0, 1) are not
> carried in a payload of the packet. 
> 
>  
> 
> 2. In case of retrieving the attribute value
> 
>   - Using getValue() in OCRepresentation object, I'm trying to get
> array values but an unexpected error occurs in compilation. Below is
> the code I used:
> 
>  
> 
> -- In onGet callback function
> 
>   int m_temp[2];
> 
>   rep.getValue("temp", m_temp);
> 
>  
> 
> And below is the error message: 
> 
> In file included from resource/include/OCApi.h:37:0,
>                  from resource/include/OCPlatform.h:30,
>                  from resource/examples/simpleclient.cpp:29:
> resource/include/OCRepresentation.h: In member function 'bool
> OC::OCRepresentation::getValue(const string&, T&) const [with T = int
> [2], std::string = std::basic_string<char>]':
> resource/examples/simpleclient.cpp:299:37:   instantiated from here
> resource/include/OCRepresentation.h:167:21: error: invalid array
> assignment
> resource/include/OCRepresentation.h:172:21: error: conversion from
> 'int' to non-scalar type 'int [2]' requested
> scons: *** [out/linux/x86_64/release/resource/examples/simpleclient.o]
> Error 1
> 
>  
> 
> Is there any sample application for me to refer to for that?
> 
>  
> 
> Thank you in advance.
> 
>  
> 
> BR, Jihun Ha.
> 
>  
> 
> ?????. ??? ??.
> 
>  
> 
> Best Regards,
> 
>  
> 
> Jihun Ha (???/???, Ph.D.)
> 
> IoT, IoTivity, OIC | IoT Solution Lab
> 
> Software R&D Center | Samsung Electronics Co., Ltd
> 
> Mobile +82 10 2533 7947  
> 
> jihun.ha at samsung.com | jhha85 at gmail.com 
> 
>  
> 
> 
> 
> 
> 
> _______________________________________________
> iotivity-dev mailing list
> iotivity-dev at lists.iotivity.org
> https://lists.iotivity.org/mailman/listinfo/iotivity-dev

Reply via email to