00001 """autogenerated by genpy from wpa_supplicant_node/Network.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007 import wpa_supplicant_node.msg
00008
00009 class Network(genpy.Message):
00010 _md5sum = "daf87d6e9247d1f494a66a6eb210e85d"
00011 _type = "wpa_supplicant_node/Network"
00012 _has_header = False
00013 _full_text = """int32 network_id
00014 bool enabled
00015 NetworkParameter[] parameters
00016
00017 ================================================================================
00018 MSG: wpa_supplicant_node/NetworkParameter
00019 string key
00020 string value
00021
00022 """
00023 __slots__ = ['network_id','enabled','parameters']
00024 _slot_types = ['int32','bool','wpa_supplicant_node/NetworkParameter[]']
00025
00026 def __init__(self, *args, **kwds):
00027 """
00028 Constructor. Any message fields that are implicitly/explicitly
00029 set to None will be assigned a default value. The recommend
00030 use is keyword arguments as this is more robust to future message
00031 changes. You cannot mix in-order arguments and keyword arguments.
00032
00033 The available fields are:
00034 network_id,enabled,parameters
00035
00036 :param args: complete set of field values, in .msg order
00037 :param kwds: use keyword arguments corresponding to message field names
00038 to set specific fields.
00039 """
00040 if args or kwds:
00041 super(Network, self).__init__(*args, **kwds)
00042
00043 if self.network_id is None:
00044 self.network_id = 0
00045 if self.enabled is None:
00046 self.enabled = False
00047 if self.parameters is None:
00048 self.parameters = []
00049 else:
00050 self.network_id = 0
00051 self.enabled = False
00052 self.parameters = []
00053
00054 def _get_types(self):
00055 """
00056 internal API method
00057 """
00058 return self._slot_types
00059
00060 def serialize(self, buff):
00061 """
00062 serialize message into buffer
00063 :param buff: buffer, ``StringIO``
00064 """
00065 try:
00066 _x = self
00067 buff.write(_struct_iB.pack(_x.network_id, _x.enabled))
00068 length = len(self.parameters)
00069 buff.write(_struct_I.pack(length))
00070 for val1 in self.parameters:
00071 _x = val1.key
00072 length = len(_x)
00073 if python3 or type(_x) == unicode:
00074 _x = _x.encode('utf-8')
00075 length = len(_x)
00076 buff.write(struct.pack('<I%ss'%length, length, _x))
00077 _x = val1.value
00078 length = len(_x)
00079 if python3 or type(_x) == unicode:
00080 _x = _x.encode('utf-8')
00081 length = len(_x)
00082 buff.write(struct.pack('<I%ss'%length, length, _x))
00083 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00084 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00085
00086 def deserialize(self, str):
00087 """
00088 unpack serialized message in str into this message instance
00089 :param str: byte array of serialized message, ``str``
00090 """
00091 try:
00092 if self.parameters is None:
00093 self.parameters = None
00094 end = 0
00095 _x = self
00096 start = end
00097 end += 5
00098 (_x.network_id, _x.enabled,) = _struct_iB.unpack(str[start:end])
00099 self.enabled = bool(self.enabled)
00100 start = end
00101 end += 4
00102 (length,) = _struct_I.unpack(str[start:end])
00103 self.parameters = []
00104 for i in range(0, length):
00105 val1 = wpa_supplicant_node.msg.NetworkParameter()
00106 start = end
00107 end += 4
00108 (length,) = _struct_I.unpack(str[start:end])
00109 start = end
00110 end += length
00111 if python3:
00112 val1.key = str[start:end].decode('utf-8')
00113 else:
00114 val1.key = str[start:end]
00115 start = end
00116 end += 4
00117 (length,) = _struct_I.unpack(str[start:end])
00118 start = end
00119 end += length
00120 if python3:
00121 val1.value = str[start:end].decode('utf-8')
00122 else:
00123 val1.value = str[start:end]
00124 self.parameters.append(val1)
00125 return self
00126 except struct.error as e:
00127 raise genpy.DeserializationError(e)
00128
00129
00130 def serialize_numpy(self, buff, numpy):
00131 """
00132 serialize message with numpy array types into buffer
00133 :param buff: buffer, ``StringIO``
00134 :param numpy: numpy python module
00135 """
00136 try:
00137 _x = self
00138 buff.write(_struct_iB.pack(_x.network_id, _x.enabled))
00139 length = len(self.parameters)
00140 buff.write(_struct_I.pack(length))
00141 for val1 in self.parameters:
00142 _x = val1.key
00143 length = len(_x)
00144 if python3 or type(_x) == unicode:
00145 _x = _x.encode('utf-8')
00146 length = len(_x)
00147 buff.write(struct.pack('<I%ss'%length, length, _x))
00148 _x = val1.value
00149 length = len(_x)
00150 if python3 or type(_x) == unicode:
00151 _x = _x.encode('utf-8')
00152 length = len(_x)
00153 buff.write(struct.pack('<I%ss'%length, length, _x))
00154 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00155 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00156
00157 def deserialize_numpy(self, str, numpy):
00158 """
00159 unpack serialized message in str into this message instance using numpy for array types
00160 :param str: byte array of serialized message, ``str``
00161 :param numpy: numpy python module
00162 """
00163 try:
00164 if self.parameters is None:
00165 self.parameters = None
00166 end = 0
00167 _x = self
00168 start = end
00169 end += 5
00170 (_x.network_id, _x.enabled,) = _struct_iB.unpack(str[start:end])
00171 self.enabled = bool(self.enabled)
00172 start = end
00173 end += 4
00174 (length,) = _struct_I.unpack(str[start:end])
00175 self.parameters = []
00176 for i in range(0, length):
00177 val1 = wpa_supplicant_node.msg.NetworkParameter()
00178 start = end
00179 end += 4
00180 (length,) = _struct_I.unpack(str[start:end])
00181 start = end
00182 end += length
00183 if python3:
00184 val1.key = str[start:end].decode('utf-8')
00185 else:
00186 val1.key = str[start:end]
00187 start = end
00188 end += 4
00189 (length,) = _struct_I.unpack(str[start:end])
00190 start = end
00191 end += length
00192 if python3:
00193 val1.value = str[start:end].decode('utf-8')
00194 else:
00195 val1.value = str[start:end]
00196 self.parameters.append(val1)
00197 return self
00198 except struct.error as e:
00199 raise genpy.DeserializationError(e)
00200
00201 _struct_I = genpy.struct_I
00202 _struct_iB = struct.Struct("<iB")