< f<dZddlZddlZddlmZmZddlZddlZddddeddd Z d Z d Z e d kriddl Z ddlZejd kse jdkrddlmZmZeee dSdS)zm Author: Vertigo Designs, Ryan Summers Description: Provides an API for controlling Booster NGFW over MQTT. N)BoosterActionzSave channel configurationnargshelpz7Tune the channel RF drain current to the specified amps)rtyper)savetunec6 |d}dt|cxkrdks nJd|dt|dkr|dnd}|r|dng}tvs Jdtd t|ks.Jd td d t|fd |DfS#t$r}td |d|d}~wwxYw)z4Parse a command string into a command and arguments.=rzInvalid command formatrN,zUnknown command specified: rz!Invalid args specified. Expected z , but found cFg|]}td|S)r )CMDS).0xcmds OC:\Users\rsummers\Documents\repositories\quartiq\booster\py\booster\__main__.py z!parse_command..,s*999qd3i'**999zFailed to parse command "z": )splitlenr Exception)entrypiecestailargs exceptionrs @r parse_commandr sfKS!!CKK$$$$1$$$$$&>$$$QiKK!OOvayy"&.tzz#Bd{{{?#??{{{Cy!S & &    ZtCy/A Z ZsSWyy Z Z   9999D999:: KKKIEIIiIIJJJKsC0C44 D>DDctjtjd}|ddtd|ddd d |d d t t dd|dddtdd}tD]<\}}|}|ddkr|dz }|ddkr|dz }||dd|ddz }=|dd |!d"}tj }| || d#S)$zMain program entry point.z'Modify booster RF channel configuration)formatter_class descriptionz--prefixzdt/sinara/booster/+z&The prefix of the booster to configure)defaultr rz --no-discoverz-d store_truezDo not discover device prefix.)actionrz --channelTzThe RF channel index to control)requiredr choicesrz--brokerz-bmqttzThe MQTT broker addresszIndividual commands. Options: rrz=xrz=x,yz<30z | r commands+rc Ktj|jtjt jd4d{V }|js$tj||jd{V\}}n|j}t||}|j D]}t|\}}|dkrD| tj|jd{Vt!d|jd^|dkrM||j|dd{V\}}t!d|jd |d d |d zd d dddd{VdS#1d{VswxYwYdS)zConfigure an RF channel.zaiomqtt-client)protocolloggerNr zChannel z configuration savedr rz: Vgs = z.3fz V, Ids = iz.2fz mA)miniconfClientbrokerMQTTv5logging getLogger no_discover discover_oneprefixrr,r perform_actionrSavechannelprint tune_bias) rclientr9_aliveboostercommandcmd_argsvgsidss rchannel_configurationz#main..channel_configuration[s@? K_$%566           # %'/'rhs> ,   I    KKK(DHDHDHN z IIIJJJ |w&&"'--//T*A*AQQQQQQQQ<<>>???DFFFFFr