| | |
| | | //client.write(new Buffer([ 0x5a, 0x00, 0x10, 0x01, 0x00, 0x07, 0xac, 0xcf, 0x23, 0xb8, 0x7f, 0xa2 ])); |
| | | //client.write(new Buffer([ 0x5A, 0x00, 0x33, 0x01, 0x00, 0x01 ])); |
| | | //client.write(new Buffer([0x5a,0x00,0x10,0x01,0x00,0x01,0xac,0xcf,0x23,0xb8,0x7f,0xbf])); |
| | | client.write(new Buffer([0x5a,0x00,0x10,0x01,0x00,0x01,0xac, 0xcf, 0x23, 0xb8, 0x7d, 0xa4])); |
| | | client.write(new Buffer([0x5a,0x00,0x00,0x01,0x00,0x01,0xac, 0xcf, 0x23, 0xb8, 0x7d, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4])); |
| | | |
| | | //client.write(new Buffer([0x5a, 0x00, 0x3d, 0x01, 0x00, 0x06, 0xac, 0xcf, 0x23, 0xb8, 0x7f, 0xbf, 0xa6, 0x6a, 0x00, 0x51, 0x01, 0x02, 0x03, 0x04, 0x10, 0x06, 0x01, 0x02, 0x00, |
| | | // , 0x03, 0xfa, 0xae, 0x3e, 0x64, 0x5e, 0x9c, 0xb3, 0xcf, 0xbb, 0x91, 0xf9, 0xe4, 0x6e, 0xab, 0xef, 0xea, 0xcf, 0x42, 0x79, 0x9a, 0xf8, 0x22, 0x18, 0xec, 0x88, 0x6c, 0x4b, 0xf0, 0x4f, 0x9f, 0xef, 0x29, 0x00, 0x00])) |
| | |
| | | var _config = global.configs[mac]; |
| | | if(_config == null) { |
| | | _config = { |
| | | mac: mac, |
| | | address: "江苏省昆山市摩瑞尔电器", |
| | | location: {
|
| | | lat:31.430616, |
| | |
| | | email: "it01@moral.org.cn",
|
| | | open_id: "o-RTuwvMHWotyirPHLmdSB_dKoQU" |
| | | } |
| | | configs[mac] = _config; |
| | | } |
| | | } |
| | | |
| | |
| | | db.collection("devices").find().toArray(function(err, docs) { |
| | | docs.forEach(function(doc) { |
| | | var mac = doc.mac; |
| | | var address = doc.address; |
| | | var location = doc.location; |
| | | var notice = doc.notice; |
| | | if(notice == null) { |
| | | var userID = doc.userID; |
| | | db.collection("users").find({"_id": userID}).limit(1).next(function(err, user){ |
| | | if(user) { |
| | | global.configs[mac] = { |
| | | address: address, |
| | | location: location, |
| | | notice: { |
| | | tel: user.username, |
| | | email: user.email, |
| | | open_id: user.open_id |
| | | if(mac != null) { |
| | | var address = doc.address || ""; |
| | | var location = doc.location || {}; |
| | | var notice = doc.notice; |
| | | if(notice == null || notice == {}) { |
| | | var userID = doc.userID; |
| | | db.collection("users").find({"_id": userID}).limit(1).next(function(err, user){ |
| | | if(user) { |
| | | global.configs[mac] = { |
| | | mac: mac, |
| | | address: address, |
| | | location: location, |
| | | notice: { |
| | | tel: user.username, |
| | | email: user.email, |
| | | open_id: user.open_id |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | global.configs[mac] = { |
| | | mac: mac, |
| | | address: address, |
| | | location: location, |
| | | notice: notice |
| | | } |
| | | }); |
| | | } else { |
| | | global.configs[mac] = { |
| | | address: address, |
| | | location: location, |
| | | notice: notice |
| | | } |
| | | } |
| | | }); |
| | |
| | | ch.bindQueue(q.queue, ex, ''); |
| | | ch.consume(q.queue, function(msg) { |
| | | var message = JSON.parse(msg.content); |
| | | var mac = message.mac; |
| | | var data = message.data; |
| | | global.configs[mac] = data; |
| | | global.configs[message.mac] = message; |
| | | }, { noAck: true }); |
| | | }); |
| | | }); |