Skip to content

Commit

Permalink
fix serial number of simulator radio messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed May 25, 2017
1 parent cba24a7 commit eaa9c09
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sim/state/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ namespace pxsim {
}

send(payload: SimulatorRadioPacketPayload) {
const b = board();
Runtime.postMessage(<SimulatorRadioPacketMessage>{
type: "radiopacket",
rssi: 0, // Not yet supported
serial: board().radioState.bus.transmitSerialNumber ? board().radioState.bus.serial : 0,
time: 0, // Not yet supported
rssi: 70, // Not yet supported
serial: b.radioState.bus.transmitSerialNumber ? pxsim.control.deviceSerialNumber() : 0,
time: new Date().getTime(),
payload
})
}
Expand All @@ -49,13 +50,11 @@ namespace pxsim {
export class RadioBus {
// uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP;
power = 0;
serial = 0;
transmitSerialNumber = false;
datagram: RadioDatagram;

constructor(private runtime: Runtime) {
this.datagram = new RadioDatagram(runtime);
this.serial = Math.floor(Math.random() * Math.pow(2, 32)) - Math.pow(2, 31); // 32 bit signed integer
}

setTransmitPower(power: number) {
Expand Down

0 comments on commit eaa9c09

Please sign in to comment.