Skip to content

Commit

Permalink
bump 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Jan 21, 2022
1 parent 7e233c4 commit c12a758
Show file tree
Hide file tree
Showing 11 changed files with 574 additions and 541 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### NOTE!!!
## After update to 2.x.x the plugin settings (xboxLiveId) need to be updated.


## [2.1.0] - (21.01.2022)
### Added
- check authorization state of console every 10 min. if powered ON and web api control enabled
- check cosole data and installed apps every 10 min. if powered ON and web api control enabled

### Changed
- send status message data only if changed
- debug message logging
- code refactor
- code cleanup
- stability and performance improvements

### Fixed
- unexpected set authorization to true however the console is not authorized
- data offset out of range [#133](https://github.com/grzegorz914/homebridge-xbox-tv/issues/133)
- incorrect client authorization on console

## [2.0.13] - (15.01.2022)

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Homebridge plugin for Microsoft game Consoles. Tested with Xbox One X/S and Xbox
| [Xbox TV](https://www.npmjs.com/package/homebridge-xbox-tv) | `npm install -g homebridge-xbox-tv` | Plug-In | Required |

## Note
* For versions 2.0.0 and above the minimum required version of Node.js is 14.x.x
* If upgrade from 1.x.x to 2.x.x and above the `xboxLiveId` need to be set again in config.
* For versions 1.4.0 and above the minimum required version of Homebridge is v1.3.x.
* For v1.4.0 and above the minimum required version of Homebridge is 1.3.x.
* For v2.0.0 and above the minimum required version of Node.js is 14.x.x.
* If upgrade from 1.x.x to 2.x.x the `xboxLiveId` need to be set again in config.

## Know Issues
* Console connected to WLAN network some times lose its connection to the network after *Power OFF* and the *Power ON* command may not work.
Expand Down
646 changes: 323 additions & 323 deletions index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Xbox TV",
"name": "homebridge-xbox-tv",
"version": "2.0.13",
"version": "2.1.0",
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
"license": "MIT",
"author": "grzegorz914",
Expand Down
45 changes: 23 additions & 22 deletions src/packet/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MESSAGE {

const Type = {
uInt32(value) {
return {
const packet = {
value: value,
pack(packetStructure) {
return packetStructure.writeUInt32(this.value);
Expand All @@ -44,9 +44,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
sInt32(value) {
return {
const packet = {
value: value,
pack(packetStructure) {
return packetStructure.writeInt32(this.value);
Expand All @@ -56,9 +57,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
uInt16(value) {
return {
const packet = {
value: value,
pack(packetStructure) {
return packetStructure.writeUInt16(this.value);
Expand All @@ -68,9 +70,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
bytes(length, value) {
return {
const packet = {
value: value,
length: length,
pack(packetStructure) {
Expand All @@ -81,9 +84,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
sgString(value) {
return {
const packet = {
value: value,
pack(packetStructure) {
return packetStructure.writeSGString(this.value);
Expand All @@ -93,10 +97,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
flags(length, value) {

return {
const packet = {
value: value,
length: length,
pack(packetStructure) {
Expand All @@ -107,9 +111,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
sgArray(structure, value) {
return {
const packet = {
value: value,
structure: structure,
pack(packetStructure) {
Expand Down Expand Up @@ -140,9 +145,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
sgList(structure, value) {
return {
const packet = {
value: value,
structure: structure,
pack(packetStructure) {
Expand Down Expand Up @@ -174,9 +180,10 @@ class MESSAGE {
return this.value;
}
}
return packet;
},
mapper(map, item) {
return {
const packet = {
item: item,
value: false,
pack(packetStructure) {
Expand All @@ -187,6 +194,7 @@ class MESSAGE {
return map[this.value];
}
}
return packet;
}
};

Expand Down Expand Up @@ -339,24 +347,17 @@ class MESSAGE {

readFlags(flags) {
flags = hexToBin(flags.toString('hex'));
let needAck = false;
let isFragment = false;

if (flags.slice(2, 3) == 1) {
needAck = true;
};
const needAck = (flags.slice(2, 3) == 1) ? true : false;
const isFragment = (flags.slice(3, 4) == 1) ? true : false;
const type = this.getMsgType(parseInt(flags.slice(4, 16), 2));

if (flags.slice(3, 4) == 1) {
isFragment = true;
};
const type = this.getMsgType(parseInt(flags.slice(4, 16), 2))

return {
const packet = {
'version': parseInt(flags.slice(0, 2), 2).toString(),
'needAck': needAck,
'isFragment': isFragment,
'type': type
};
return packet;
};

setFlags(type) {
Expand Down
42 changes: 19 additions & 23 deletions src/packet/packer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,49 @@ const Types = {
cc00: 'simple.connectRequest',
cc01: 'simple.connectResponse',
dd00: 'simple.discoveryRequest',
dd01: 'simple.discovery',
dd01: 'simple.discoveryResponse',
dd02: 'simple.powerOn',
};

class PACKER {
constructor(type) {
const packetType = type.slice(0, 2).toString('hex');
this.structure = '';
this.type = type;

let structure = '';
if (packetType in Types) {
// We got a packet that we need to unpack
const packetValue = this.type;
this.type = Types[packetType];
this.structure = this.loadPacketStructure(this.type, packetValue);
const packetValue = type;
type = Types[packetType];
this.packetStructure = this.loadPacketStructure(type, packetValue);
} else {
this.structure = this.loadPacketStructure(this.type);
this.packetStructure = this.loadPacketStructure(type);
};
this.structure = this.packetStructure;
this.type = type;
};

loadPacketStructure(type, value = false) {
if (type.slice(0, 6) == 'simple') {
return new SimplePacket(type.slice(7), value);
} else if (type.slice(0, 7) == 'message') {
return new MessagePacket(type.slice(8), value);
} else {
return false;
};
};

set(key, value, protectedPayload = false) {
this.structure.set(key, value, protectedPayload);
};

pack(smartglass = undefined) {
return this.structure.pack(smartglass);
return this.packetStructure.pack(smartglass);
};

unpack(smartglass = undefined) {
return this.structure.unpack(smartglass);
return this.packetStructure.unpack(smartglass);
};

setChannel(channelId) {
this.structure.setChannel(channelId);
};

loadPacketStructure(type, value = false) {
if (type.slice(0, 6) == 'simple') {
this.simplePacket = new SimplePacket(type.slice(7), value);
return this.simplePacket;
} else if (type.slice(0, 7) == 'message') {
this.messagePacket = new MessagePacket(type.slice(8), value);
return this.messagePacket;
} else {
return false;
};
};
};
module.exports = PACKER;
Loading

0 comments on commit c12a758

Please sign in to comment.