36 { name: 'os_version' }, |
36 { name: 'os_version' }, |
37 { name: 'FW' }, |
37 { name: 'FW' }, |
38 { name: 'server_port', type: 'int' }, |
38 { name: 'server_port', type: 'int' }, |
39 { name: 'websocket_port', type: 'int' }, |
39 { name: 'websocket_port', type: 'int' }, |
40 { name: 'nextunit', type: 'int' }, |
40 { name: 'nextunit', type: 'int' }, |
41 { name: 'thb_temp_uuid', map: 'THB>temperature>uuid' }, |
|
42 { name: 'temp_uuid', map: 'THB>temperature>uuid' }, |
41 { name: 'temp_uuid', map: 'THB>temperature>uuid' }, |
43 { name: 'temp_state', map: 'THB>temperature>state' }, |
42 { name: 'temp_state', map: 'THB>temperature>state' }, |
44 { name: 'temp_value', map: 'THB>temperature>value', type: 'int' }, |
43 { name: 'temp_value', map: 'THB>temperature>value', type: 'float' }, |
45 { name: 'hum_uuid', map: 'THB>humidity>uuid' }, |
44 { name: 'hum_uuid', map: 'THB>humidity>uuid' }, |
46 { name: 'hum_state', map: 'THB>humidity>state' }, |
45 { name: 'hum_state', map: 'THB>humidity>state' }, |
47 { name: 'hum_value', map: 'THB>humidity>value', type: 'int' }, |
46 { name: 'hum_value', map: 'THB>humidity>value', type: 'float' }, |
48 { name: 'temp_hum_idx', map: 'THB>index', type: 'int' }, |
47 { name: 'temp_hum_idx', map: 'THB>index', type: 'int' }, |
49 { name: 'lcd_address', map: 'LCD>address' }, |
48 { name: 'lcd_address', map: 'LCD>address' }, |
50 { name: 'lcd_cols', map: 'LCD>cols', type: 'int' }, |
49 { name: 'lcd_cols', map: 'LCD>cols', type: 'int' }, |
51 { name: 'lcd_rows', map: 'LCD>rows', type: 'int' }, |
50 { name: 'lcd_rows', map: 'LCD>rows', type: 'int' }, |
52 { name: 'mqtt_host', map: 'MQTT>host' }, |
51 { name: 'mqtt_host', map: 'MQTT>host' }, |
68 $('#server_port').val(global.server_port); |
67 $('#server_port').val(global.server_port); |
69 $('#websocket_port').val(global.websocket_port); |
68 $('#websocket_port').val(global.websocket_port); |
70 $('#nextunit').val(global.nextunit); |
69 $('#nextunit').val(global.nextunit); |
71 $('#temp_uuid').val(global.temp_uuid); |
70 $('#temp_uuid').val(global.temp_uuid); |
72 $('#temp_state').val(global.temp_state); |
71 $('#temp_state').val(global.temp_state); |
73 $('#temp_value').val(global.temp_value / 1000.0); |
72 $('#temp_value').val(global.temp_value); |
74 $('#hum_uuid').val(global.hum_uuid); |
73 $('#hum_uuid').val(global.hum_uuid); |
75 $('#hum_state').val(global.hum_state); |
74 $('#hum_state').val(global.hum_state); |
76 $('#hum_value').val(global.hum_value / 1000.0); |
75 $('#hum_value').val(global.hum_value); |
77 $('#temp_hum_idx').val(global.temp_hum_idx); |
76 $('#temp_hum_idx').val(global.temp_hum_idx); |
78 $('#lcd_address').val(global.lcd_address); |
77 $('#lcd_address').val(global.lcd_address); |
79 $('#lcd_cols').val(global.lcd_cols); |
78 $('#lcd_cols').val(global.lcd_cols); |
80 $('#lcd_rows').val(global.lcd_rows) |
79 $('#lcd_rows').val(global.lcd_rows) |
81 $('#mqtt_host').val(global.mqtt_host); |
80 $('#mqtt_host').val(global.mqtt_host); |
159 alert('Error: ' + data.msg); |
158 alert('Error: ' + data.msg); |
160 } else { |
159 } else { |
161 console.log('update: success'); |
160 console.log('update: success'); |
162 } |
161 } |
163 }, |
162 }, |
164 error: function(jqXHR, textStatus, errorThrown) { |
163 error: function(jqXHR, textStatus, errorThrown) {} |
165 } |
|
166 }); |
164 }); |
167 }); |
165 }); |
168 |
166 |
169 websocket.onmessage = function(evt) { |
167 websocket.onmessage = function(evt) { |
170 var msg = evt.data; |
168 var msg = evt.data; |
171 var obj = JSON.parse(msg); |
169 var obj = JSON.parse(msg); |
172 |
170 |
173 if (obj.ping) { |
171 if (obj.ping) { |
174 websocket.send('{"pong":' + obj.ping + '}'); |
172 websocket.send('{"pong":' + obj.ping + '}'); |
175 } |
173 } |
176 |
|
177 if (obj.type == 'global') { |
|
178 // Use the message to trigger update. |
|
179 // $('#jqxgrid').jqxGrid('updatebounddata'); |
|
180 } |
|
181 } |
174 } |
182 }); |
175 }); |