Skip to content

Commit

Permalink
[ble] Simplify packet format
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Jul 5, 2016
1 parent e6baafd commit 4eeb186
Showing 1 changed file with 15 additions and 57 deletions.
72 changes: 15 additions & 57 deletions platforms/ble/ble_minidrone.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,65 +277,23 @@ func (b *BLEMinidroneDriver) Outdoor(outdoor bool) error {
}

func (b *BLEMinidroneDriver) generatePcmd() *bytes.Buffer {
cmd := &bytes.Buffer{}
tmp := &bytes.Buffer{}

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(2))
cmd.Write(tmp.Bytes())

b.stepsfa0a++
tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(b.stepsfa0a))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(2))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(0))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(2))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(0))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(b.Pcmd.Flag))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(b.Pcmd.Roll))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(b.Pcmd.Pitch))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(b.Pcmd.Yaw))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int8(b.Pcmd.Gaz))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, float32(b.Pcmd.Psi))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int16(0))
cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, int16(0))
cmd.Write(tmp.Bytes())
cmd := &bytes.Buffer{}
binary.Write(cmd, binary.LittleEndian, int8(2))
binary.Write(cmd, binary.LittleEndian, int8(b.stepsfa0a))
binary.Write(cmd, binary.LittleEndian, int8(2))
binary.Write(cmd, binary.LittleEndian, int8(0))
binary.Write(cmd, binary.LittleEndian, int8(2))
binary.Write(cmd, binary.LittleEndian, int8(0))
binary.Write(cmd, binary.LittleEndian, int8(b.Pcmd.Flag))
binary.Write(cmd, binary.LittleEndian, int8(b.Pcmd.Roll))
binary.Write(cmd, binary.LittleEndian, int8(b.Pcmd.Pitch))
binary.Write(cmd, binary.LittleEndian, int8(b.Pcmd.Yaw))
binary.Write(cmd, binary.LittleEndian, int8(b.Pcmd.Gaz))
binary.Write(cmd, binary.LittleEndian, float32(b.Pcmd.Psi))
binary.Write(cmd, binary.LittleEndian, int16(0))
binary.Write(cmd, binary.LittleEndian, int16(0))

return cmd
}

0 comments on commit 4eeb186

Please sign in to comment.