def configureDeviceConfiguration(args, faradayConfigPath):
    '''
    Configure device configuration configuration file from command line

    :param args: argparse arguments
    :return: None
    '''

    config = ConfigParser.RawConfigParser()
    config.read(deviceConfigPath)

    fconfig = ConfigParser.RawConfigParser()
    fconfig.read(faradayConfigPath)

    # Obtain proxy configuration
    # TODO: Not hardcode
    proxyConfiguration = proxyConfig("127.0.0.1", 8000)

    #Only works for UNIT0 at this time
    config.set('DEVICES', 'CALLSIGN', proxyConfiguration["UNIT0"].get("callsign"))
    config.set('DEVICES', 'NODEID', proxyConfiguration["UNIT0"].get("nodeid"))

    # Faraday radio configuration
    if args.callsign is not None:
        fconfig.set('BASIC', 'CALLSIGN', args.callsign)
    if args.nodeid is not None:
        fconfig.set('BASIC', 'ID', args.nodeid)

    # Obtain configboot bitmask options
    if args.redledtxon:
        fconfig.set('BASIC', 'REDLEDTX', 1)
    if args.redledtxoff:
        fconfig.set('BASIC', 'REDLEDTX', 0)
    if args.greenledrxon:
        fconfig.set('BASIC', 'GREENLEDRX', 1)
    if args.greenledrxoff:
        fconfig.set('BASIC', 'GREENLEDRX', 0)
    if args.unitconfigured:
        fconfig.set('BASIC', 'UNITCONFIGURED', 1)
    if args.unitunconfigured:
        fconfig.set('BASIC', 'UNITCONFIGURED', 0)

    # Create configuration boot bitmask integer
    bootmask = [0] * 8
    redledtx = fconfig.get('BASIC', 'REDLEDTX')
    greenledrx = fconfig.get('BASIC', 'GREENLEDRX')
    unitconfigured = fconfig.get('BASIC', 'UNITCONFIGURED')
    bootmask[5] = greenledrx
    bootmask[6] = redledtx
    bootmask[7] = unitconfigured
    configbootbitmask = eightBitListToInt(bootmask)
    fconfig.set('BASIC', 'CONFIGBOOTBITMASK', configbootbitmask)

    # Detect and set GPIO P3 settings, create bitmask
    if args.gpiop3on >= 0 and args.gpiop3on <= 7:
        if args.gpiop3on is not None:
            fconfig.set('BASIC', 'GPIO_P3_' + str(args.gpiop3on), 1)
    if args.gpiop3off >= 0 and args.gpiop3off <= 7:
        if args.gpiop3off is not None:
            fconfig.set('BASIC', 'GPIO_P3_' + str(args.gpiop3off), 0)

    gpiomask = [0] * 8
    if not args.gpiop3clear:
        gpio0 = fconfig.get('BASIC', 'GPIO_P3_0')
        gpio1 = fconfig.get('BASIC', 'GPIO_P3_1')
        gpio2 = fconfig.get('BASIC', 'GPIO_P3_2')
        gpio3 = fconfig.get('BASIC', 'GPIO_P3_3')
        gpio4 = fconfig.get('BASIC', 'GPIO_P3_4')
        gpio5 = fconfig.get('BASIC', 'GPIO_P3_5')
        gpio6 = fconfig.get('BASIC', 'GPIO_P3_6')
        gpio7 = fconfig.get('BASIC', 'GPIO_P3_7')
        gpiomask = [gpio7, gpio6, gpio5, gpio4, gpio3, gpio2, gpio1, gpio0]
    if args.gpiop3clear:
        fconfig.set('BASIC', 'GPIO_P3_0', 0)
        fconfig.set('BASIC', 'GPIO_P3_1', 0)
        fconfig.set('BASIC', 'GPIO_P3_2', 0)
        fconfig.set('BASIC', 'GPIO_P3_3', 0)
        fconfig.set('BASIC', 'GPIO_P3_4', 0)
        fconfig.set('BASIC', 'GPIO_P3_5', 0)
        fconfig.set('BASIC', 'GPIO_P3_6', 0)
        fconfig.set('BASIC', 'GPIO_P3_7', 0)

    gpiop3bitmask = eightBitListToInt(gpiomask)
    fconfig.set('BASIC', 'GPIO_P3', gpiop3bitmask)

    # Detect and set GPIO P4 settings, create bitmask
    if args.gpiop4on >= 0 and args.gpiop4on <= 7:
        if args.gpiop4on is not None:
            fconfig.set('BASIC', 'GPIO_P4_' + str(args.gpiop4on), 1)
    if args.gpiop4off >= 0 and args.gpiop4off <= 7:
        if args.gpiop4off is not None:
            fconfig.set('BASIC', 'GPIO_P4_' + str(args.gpiop4off), 0)

    gpiomask = [0] * 8
    if not args.gpiop4clear:
        gpio0 = fconfig.get('BASIC', 'GPIO_P4_0')
        gpio1 = fconfig.get('BASIC', 'GPIO_P4_1')
        gpio2 = fconfig.get('BASIC', 'GPIO_P4_2')
        gpio3 = fconfig.get('BASIC', 'GPIO_P4_3')
        gpio4 = fconfig.get('BASIC', 'GPIO_P4_4')
        gpio5 = fconfig.get('BASIC', 'GPIO_P4_5')
        gpio6 = fconfig.get('BASIC', 'GPIO_P4_6')
        gpio7 = fconfig.get('BASIC', 'GPIO_P4_7')
        gpiomask = [gpio7, gpio6, gpio5, gpio4, gpio3, gpio2, gpio1, gpio0]
    if args.gpiop4clear:
        fconfig.set('BASIC', 'GPIO_P4_0', 0)
        fconfig.set('BASIC', 'GPIO_P4_1', 0)
        fconfig.set('BASIC', 'GPIO_P4_2', 0)
        fconfig.set('BASIC', 'GPIO_P4_3', 0)
        fconfig.set('BASIC', 'GPIO_P4_4', 0)
        fconfig.set('BASIC', 'GPIO_P4_5', 0)
        fconfig.set('BASIC', 'GPIO_P4_6', 0)
        fconfig.set('BASIC', 'GPIO_P4_7', 0)

    gpiop4bitmask = eightBitListToInt(gpiomask)
    fconfig.set('BASIC', 'GPIO_P4', gpiop4bitmask)

    # Detect and set GPIO P5 settings, create bitmask
    if args.gpiop5on >= 0 and args.gpiop5on <= 7:
        if args.gpiop5on is not None:
            fconfig.set('BASIC', 'GPIO_P5_' + str(args.gpiop5on), 1)
    if args.gpiop5off >= 0 and args.gpiop5off <= 7:
        if args.gpiop5off is not None:
            fconfig.set('BASIC', 'GPIO_P5_' + str(args.gpiop5off), 0)

    gpiomask = [0] * 8
    if not args.gpiop5clear:
        gpio0 = fconfig.get('BASIC', 'GPIO_P5_0')
        gpio1 = fconfig.get('BASIC', 'GPIO_P5_1')
        gpio2 = fconfig.get('BASIC', 'GPIO_P5_2')
        gpio3 = fconfig.get('BASIC', 'GPIO_P5_3')
        gpio4 = fconfig.get('BASIC', 'GPIO_P5_4')
        gpio5 = fconfig.get('BASIC', 'GPIO_P5_5')
        gpio6 = fconfig.get('BASIC', 'GPIO_P5_6')
        gpio7 = fconfig.get('BASIC', 'GPIO_P5_7')
        gpiomask = [gpio7, gpio6, gpio5, gpio4, gpio3, gpio2, gpio1, gpio0]
    if args.gpiop5clear:
        fconfig.set('BASIC', 'GPIO_P5_0', 0)
        fconfig.set('BASIC', 'GPIO_P5_1', 0)
        fconfig.set('BASIC', 'GPIO_P5_2', 0)
        fconfig.set('BASIC', 'GPIO_P5_3', 0)
        fconfig.set('BASIC', 'GPIO_P5_4', 0)
        fconfig.set('BASIC', 'GPIO_P5_5', 0)
        fconfig.set('BASIC', 'GPIO_P5_6', 0)
        fconfig.set('BASIC', 'GPIO_P5_7', 0)

    gpiop5bitmask = eightBitListToInt(gpiomask)
    fconfig.set('BASIC', 'GPIO_P5', gpiop5bitmask)

    if args.bootfrequency is not None:
        fconfig.set('RF', 'boot_frequency_mhz', args.bootfrequency)
    if args.bootrfpower is not None:
        fconfig.set('RF', 'boot_rf_power', args.bootrfpower)
    if args.latitude is not None:
        fconfig.set('GPS', 'default_latitude', args.latitude)
    if args.longitude is not None:
        fconfig.set('GPS', 'default_longitude', args.longitude)
    if args.latitudedir is not None:
        fconfig.set('GPS', 'default_latitude_direction', args.latitudedir)
    if args.longitudedir is not None:
        fconfig.set('GPS', 'default_longitude_direction', args.longitudedir)
    if args.altitude is not None:
        fconfig.set('GPS', 'default_altitude', args.altitude)
    if args.gpsbooton:
        fconfig.set('GPS', 'gps_boot_bit', 1)
    if args.gpsbootoff:
        fconfig.set('GPS', 'gps_boot_bit', 0)
    if args.gpsenabled:
        fconfig.set('GPS', 'gps_present_bit', 1)
    if args.gpsdisabled:
        fconfig.set('GPS', 'gps_present_bit', 0)
    if args.uarttelemetryenabled:
        fconfig.set('TELEMETRY', 'uart_telemetry_boot_bit', 1)
    if args.uarttelemetrydisabled:
        fconfig.set('TELEMETRY', 'uart_telemetry_boot_bit', 0)
    if args.rftelemetryenabled:
        fconfig.set('TELEMETRY', 'rf_telemetry_boot_bit', 1)
    if args.rftelemetrydisabled:
        fconfig.set('TELEMETRY', 'rf_telemetry_boot_bit', 0)
    if args.uartinterval is not None and args.uartinterval > 0:
        fconfig.set('TELEMETRY', 'telemetry_default_uart_interval', args.uartinterval)
    if args.rfinterval is not None and args.rfinterval > 0:
        fconfig.set('TELEMETRY', 'telemetry_default_rf_interval', args.rfinterval)

    # Save device configuration
    with open(deviceConfigPath, 'wb') as configfile:
        config.write(configfile)

    # Save Faraday configuration
    with open(faradayConfigPath, 'wb') as configfile:
        fconfig.write(configfile)