To simplify usage of BLE112 and other Bluegiga Smart modules, use BGScript code below in order to flash BGScript programs via USB. You can also create custom task inside VS Code to flash the device with keyboard shortcut.
dim ret_result, ret_data_size, ret_data(2)
# watch for new data from USB CDC
# NOTE! This function or something similar MUST remain in the BGScript to
# allow access to DFU mode over USB CDC with a special trigger character
event system_endpoint_watermark_rx(endpoint, data_len)
call system_endpoint_rx(endpoint, data_len)(ret_result, ret_data_size, ret_data(0:ret_data_size))
if ret_data(0:1) = $30 then # ASCII '0' is 0x30
# reboot into DFU mode when 0x30 is received
call system_reset(1)
end if
end