You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.1 KiB
52 lines
1.1 KiB
/* Protocol - protocol constants */ |
|
|
|
/* Command code => mnemonic */ |
|
module.exports.types = { |
|
0: 'reserved', |
|
1: 'connect', |
|
2: 'connack', |
|
3: 'publish', |
|
4: 'puback', |
|
5: 'pubrec', |
|
6: 'pubrel', |
|
7: 'pubcomp', |
|
8: 'subscribe', |
|
9: 'suback', |
|
10: 'unsubscribe', |
|
11: 'unsuback', |
|
12: 'pingreq', |
|
13: 'pingresp', |
|
14: 'disconnect', |
|
15: 'reserved' |
|
}; |
|
|
|
/* Mnemonic => Command code */ |
|
module.exports.codes = {} |
|
for(var k in module.exports.types) { |
|
var v = module.exports.types[k]; |
|
module.exports.codes[v] = k; |
|
} |
|
|
|
/* Header */ |
|
module.exports.CMD_SHIFT = 4; |
|
module.exports.CMD_MASK = 0xF0; |
|
module.exports.DUP_MASK = 0x08; |
|
module.exports.QOS_MASK = 0x03; |
|
module.exports.QOS_SHIFT = 1; |
|
module.exports.RETAIN_MASK = 0x01; |
|
|
|
/* Length */ |
|
module.exports.LENGTH_MASK = 0x7F; |
|
module.exports.LENGTH_FIN_MASK = 0x80; |
|
|
|
/* Connack */ |
|
module.exports.SESSIONPRESENT_MASK = 0x01; |
|
|
|
/* Connect */ |
|
module.exports.USERNAME_MASK = 0x80; |
|
module.exports.PASSWORD_MASK = 0x40; |
|
module.exports.WILL_RETAIN_MASK = 0x20; |
|
module.exports.WILL_QOS_MASK = 0x18; |
|
module.exports.WILL_QOS_SHIFT = 3; |
|
module.exports.WILL_FLAG_MASK = 0x04; |
|
module.exports.CLEAN_SESSION_MASK = 0x02;
|
|
|