 parse_control_point_response = (response_code, data, cb)->
     expected_size = (size)->
         if data.length != size
-            throw "while parsing response (code=#{response_code}), the response expected to be #{size} in size, but was #{data.length}"
+            raise "while parsing response (code=#{response_code}), the response expected to be #{size} in size, but was #{data.length}"
 
     switch response_code
         when OPC_GET_VERSION

            parse_control_point_response response_code, data, cb

    buffer = new Buffer( [ opcode ] )
    control_point_char.write buffer, false, (error)->
        if error
            cb( error )


noble   = require 'noble'
util    = require 'util'
fs      = require 'fs'
options = require('minimist')(
    process.argv.slice(2), {
        boolean: ['help', 'version', 'list'],
        string: ['address', 'device', 'flash'],
        alias: {
            'help': ['h'],
            'address': ['a'],
            'device' : ['d'],
            'version': ['v'],
            'list'   : ['l'],
            'flash'  : ['f']
        }
        unknown: ( field )-> raise "Unrecognizes argument \"#{field}\""
    })

BOOTLOADER_SERVICE_UUID     = '7d295f4d28504f57b595837f5753f8a9'
