Module proxy class holding the default parameter of a Tello.
| 23 | |
| 24 | |
| 25 | class TelloModule(DJIModule): |
| 26 | """ Module proxy class holding the default parameter of a Tello. """ |
| 27 | config = Config({ |
| 28 | Option( |
| 29 | 'IP', |
| 30 | "IP address of drone's AP", |
| 31 | True, |
| 32 | ): "192.168.10.1", |
| 33 | Option( |
| 34 | 'FLYCTL_PORT', |
| 35 | "Fly controller port", |
| 36 | True, |
| 37 | ): 8889, |
| 38 | Option( |
| 39 | 'TARGET', |
| 40 | "Target's SSID", |
| 41 | True, |
| 42 | choices=lambda o: [e for e in o.state['TARGETS'].keys() if drone_filter(e, o.module.drone) and \ |
| 43 | e in o.console.root.connected_targets], |
| 44 | ): None, |
| 45 | }) |
| 46 | drone = "DJI Tello" |
| 47 | fly_params = { |
| 48 | 'commands': { |
| 49 | 'emergency': ("Emergency stop...", "Emergency stop not done"), |
| 50 | 'land': ("Landing the target...", "Landing not done"), |
| 51 | 'takeoff': ("Taking off the target...", "Takeoff not done"), |
| 52 | 'temp?': ("Getting temperature...", "Temperature not retrieved"), |
| 53 | }, |
| 54 | 'post': lambda s, t, p: s.sendto(b"command", t), |
| 55 | 'pre': lambda s, t, p: s.sendto(b"command", t), |
| 56 | 'result': lambda r: True if r.strip().lower() == b"ok" else False if r.strip().lower() == b"unknown command!" \ |
| 57 | else None, |
| 58 | 'socket': socket.SOCK_DGRAM, |
| 59 | } |
| 60 | path = "command/dji/tello" |
| 61 | |
| 62 | def _change_ap_creds(self, ssid, pswd, new_ssid=True): |
| 63 | i = ["password", "SSID"][new_ssid] |
| 64 | self.logger.info("Changing %s..." % i) |
| 65 | r = self.send_command("wifi '%s' '%s'" % (ssid, pswd)) |
| 66 | self._feedback(r, "AP %s not changed" % i) |
| 67 | if not new_ssid: |
| 68 | self.console.state['TARGETS'][ssid]['password'] = pswd |
| 69 | self.console.state['PASSWORDS'][ssid] = pswd |
| 70 | return r |
| 71 | |
| 72 | def _send_udp_command(self, command): |
| 73 | msg = TelloModule.fly_params['commands'].get(command) |
| 74 | if msg is not None: |
| 75 | self.logger.info(msg[0]) |
| 76 | r = self.send_command(command) |
| 77 | self._feedback(r, msg[1]) |
| 78 | return r |
| 79 | raise Exception("Bad UDP command") |
| 80 |
nothing calls this directly
no test coverage detected