aws_topic_subscriber - bruno-beloff/scs_dev GitHub Wiki

docs > software repositories > scs_dev > commands > manipulating nodes within JSON documents


DESCRIPTION

The aws_topic_subscriber utility is used to select subscribed data from the output of the aws_mqtt_client script, and make it available to a listening process.

The aws_topic_subscriber script is needed because the - given that only one instance per host may be running - the aws_mqtt_client may be subscribing to multiple topics. The aws_topic_subscriber only responds to one specific topic. It expects a JSON document of the form provided by aws_mqtt_client. It acts by returning the value of the field whose field name matches the topic name.

Messaging topics can be specified either by a project channel name, or by an explicit topic path. If a project channel name is used, the aws_topic_subscriber utility requires system ID and AWS project configurations to be set.

SYNOPSIS

aws_topic_subscriber.py { -t TOPIC | -c { C | G | P | S | X } } [-s UDS_SUB] [-v]

Options
--version show program's version number and exit
-h, --help show this help message and exit
-t TOPIC, --topic=TOPIC topic path
-c CHANNEL, --channel=CHANNEL publication channel
-s UDS_SUB, --sub=UDS_SUB read subscriptions from UDS instead of stdin
-v, --verbose report narrative to stderr

EXAMPLES

/home/pi/SCS/scs_dev/src/scs_dev/aws_topic_subscriber.py -cX -s /home/pi/SCS/pipes/mqtt_control_subscription.uds | /home/pi/SCS/scs_dev/src/scs_dev/control_receiver.py -r -v

DOCUMENT EXAMPLE - INPUT

{"south-coast-science-dev/production-test/loc/1/gases": {"tag": "scs-be2-2", "rec": "2018-04-04T13:05:52.675+00:00", "val": {"NO2": {"weV": 0.316192, "aeV": 0.310317, "weC": 0.002991, "cnc": 22.6}, "CO": {"weV": 0.286567, "aeV": 0.258941, "weC": 0.043378, "cnc": 181.5}, "SO2": {"weV": 0.263879, "aeV": 0.267942, "weC": -0.01022, "cnc": -12.8}, "H2S": {"weV": 0.209753, "aeV": 0.255191, "weC": -0.031478, "cnc": 11.9}, "sht": {"hmd": 57.0, "tmp": 21.3}}}}

DOCUMENT EXAMPLE - OUTPUT

{"tag": "scs-be2-2", "rec": "2018-04-04T13:05:52.675+00:00", "val": {"NO2": {"weV": 0.316192, "aeV": 0.310317, "weC": 0.002991, "cnc": 22.6}, "CO": {"weV": 0.286567, "aeV": 0.258941, "weC": 0.043378, "cnc": 181.5}, "SO2": {"weV": 0.263879, "aeV": 0.267942, "weC": -0.01022, "cnc": -12.8}, "H2S": {"weV": 0.209753, "aeV": 0.255191, "weC": -0.031478, "cnc": 11.9}, "sht": {"hmd": 57.0, "tmp": 21.3}}}

SEE ALSO

scs_dev/aws_mqtt_client

scs_mfr/aws_project
scs_mfr/system_id