Module: Particle::Client::Firmware
- Included in:
- Particle::Client
- Defined in:
- lib/particle/client/firmware.rb
Overview
Client methods for the Particle firmware flash API
Constant Summary collapse
- COMPILE_PATH =
"v1/binaries"
- PLATFORMS =
{ core: 0, photon: 6, p1: 8, electron: 10 }
Instance Method Summary collapse
-
#compile(file_paths, options = {}) ⇒ OpenStruct
Compile firmware from source code for a specific Particle device.
-
#download_binary(binary_id) ⇒ String
Download compiled binary firmware.
-
#flash_device(target, file_paths, options = {}) ⇒ OpenStruct
Flash new firmware to a Particle device from source code or binary.
Instance Method Details
#compile(file_paths, options = {}) ⇒ OpenStruct
Compile firmware from source code for a specific Particle device
54 55 56 57 58 59 |
# File 'lib/particle/client/firmware.rb', line 54 def compile(file_paths, = {}) normalize_platform_id() params = file_upload_params(file_paths, ) result = post(COMPILE_PATH, params) OpenStruct.new(result) end |
#download_binary(binary_id) ⇒ String
Download compiled binary firmware
66 67 68 |
# File 'lib/particle/client/firmware.rb', line 66 def download_binary(binary_id) get(binary_path(binary_id)) end |
#flash_device(target, file_paths, options = {}) ⇒ OpenStruct
Flash new firmware to a Particle device from source code or binary
32 33 34 35 36 37 38 39 |
# File 'lib/particle/client/firmware.rb', line 32 def flash_device(target, file_paths, = {}) params = file_upload_params(file_paths, ) result = put(device(target).path, params) if result[:status] == "Update started" result[:ok] = true end OpenStruct.new(result) end |