Skip to content

Commit

Permalink
Tools: ardupilotwaf: allow automatic upload to BlueOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Aug 22, 2024
1 parent 32cee97 commit d3d4867
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Tools/ardupilotwaf/ardupilotwaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ def ap_common_vehicle_libraries(bld):

_grouped_programs = {}


class upload_fw_blueos(Task.Task):
def run(self):
import requests
binary_path = self.inputs[0].abspath()
bld = self.generator.bld
board = bld.bldnode.name.capitalize()
url = f'{bld.options.upload_blueos}/ardupilot-manager/v1.0/install_firmware_from_file?board_name={board}'
files = {
'binary': open(binary_path, 'rb')
}
response = requests.post(url, files=files, verify=False)

def keyword(self):
return "Uploading to BlueOS"

class check_elf_symbols(Task.Task):
color='CYAN'
always_run = True
Expand Down Expand Up @@ -309,6 +325,10 @@ def post_link(self):

check_elf_task = self.create_task('check_elf_symbols', src=link_output)
check_elf_task.set_run_after(self.link_task)
if self.bld.options.upload_blueos:
_upload_task = self.create_task('upload_fw_blueos', src=link_output)
_upload_task.set_run_after(self.link_task)


@conf
def ap_program(bld,
Expand Down Expand Up @@ -641,6 +661,13 @@ def options(opt):
help='''Specify the port to be used with the --upload option. For example a port of /dev/ttyS10 indicates that serial port 10 shuld be used.
''')

g.add_option('--upload-blueos',
action='store',
dest='upload_blueos',
default=None,
help='''Automatically upload to a BlueOS device. The argument is the url for the device. http://blueos.local for example.
''')

g.add_option('--upload-force',
action='store_true',
help='''Override board type check and continue loading. Same as using uploader.py --force.
Expand Down

0 comments on commit d3d4867

Please sign in to comment.