diff --git a/platforms/bebop/bebop_adaptor.go b/platforms/bebop/bebop_adaptor.go index 9bb2e6441..058e526bd 100644 --- a/platforms/bebop/bebop_adaptor.go +++ b/platforms/bebop/bebop_adaptor.go @@ -22,6 +22,8 @@ type drone interface { Stop() error Connect() error Video() chan []byte + StartRecording() error + StopRecording() error } // BebopAdaptor is gobot.Adaptor representation for the Bebop diff --git a/platforms/bebop/bebop_driver.go b/platforms/bebop/bebop_driver.go index 3e6da8467..263628683 100644 --- a/platforms/bebop/bebop_driver.go +++ b/platforms/bebop/bebop_driver.go @@ -113,3 +113,13 @@ func (a *BebopDriver) Stop() { func (a *BebopDriver) Video() chan []byte { return a.adaptor().drone.Video() } + +// StartRecording starts the recording video to the drones interal storage +func (a *BebopDriver) StartRecording() error { + return a.adaptor().drone.StartRecording() +} + +// StopRecording stops a previously started recording +func (a *BebopDriver) StopRecording() error { + return a.adaptor().drone.StopRecording() +} diff --git a/platforms/bebop/client/client.go b/platforms/bebop/client/client.go index d3016566d..76721fff0 100644 --- a/platforms/bebop/client/client.go +++ b/platforms/bebop/client/client.go @@ -545,6 +545,48 @@ func (b *Bebop) packetReceiver(buf []byte) { } } +func (b *Bebop) StartRecording() error { + buf := b.videoRecord(ARCOMMANDS_ARDRONE3_MEDIARECORD_VIDEO_RECORD_START) + + b.write(b.networkFrameGenerator(buf, ARNETWORKAL_FRAME_TYPE_DATA, BD_NET_CD_NONACK_ID).Bytes()) + return nil +} + +func (b *Bebop) StopRecording() error { + buf := b.videoRecord(ARCOMMANDS_ARDRONE3_MEDIARECORD_VIDEO_RECORD_STOP) + + b.write(b.networkFrameGenerator(buf, ARNETWORKAL_FRAME_TYPE_DATA, BD_NET_CD_NONACK_ID).Bytes()) + return nil +} + +func (b *Bebop) videoRecord(state byte) *bytes.Buffer { + // + // ARCOMMANDS_Generator_GenerateARDrone3MediaRecordVideo + // + + cmd := &bytes.Buffer{} + + cmd.WriteByte(ARCOMMANDS_ID_PROJECT_ARDRONE3) + cmd.WriteByte(ARCOMMANDS_ID_ARDRONE3_CLASS_MEDIARECORD) + + tmp := &bytes.Buffer{} + binary.Write(tmp, + binary.LittleEndian, + uint16(ARCOMMANDS_ID_ARDRONE3_MEDIARECORD_CMD_VIDEO), + ) + + cmd.Write(tmp.Bytes()) + + tmp = &bytes.Buffer{} + binary.Write(tmp, binary.LittleEndian, uint32(state)) + + cmd.Write(tmp.Bytes()) + + cmd.WriteByte(0) + + return cmd +} + func (b *Bebop) Video() chan []byte { return b.video }