diff --git a/zephyr/samples/profiles/b-ld/README.rst b/zephyr/samples/profiles/b-ld/README.rst index 55637f8..b488408 100644 --- a/zephyr/samples/profiles/b-ld/README.rst +++ b/zephyr/samples/profiles/b-ld/README.rst @@ -52,3 +52,25 @@ Compile this sample for the `rpi_pico` board: Compile this sample for the `adafruit_grand_central_m4_express` board with west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/ + +Using the Shell +*************** + +The shell is available on some boards via virtual communication port: + + picocom --baud 115200 /dev/ttyACM0 + + Terminal ready + *** Booting Zephyr OS build v3.7.0 *** + [00:00:00.012,000] bacnet: BACnet Device: BACnet Lighting Device (B-LD) + [00:00:00.012,000] bacnet: BACnet Stack Version 1.4.1 + [00:00:00.012,000] bacnet: BACnet Stack Max APDU: 1476 + uart:~$ + bacnet clear device devmem help history kernel net + rem resize retval shell stats + uart:~$ bacnet objects + {"object-list": [ + {"object-identifier":{"device":4194303}}, + {"object-identifier":{"network-port":0}}, + {"object-identifier":{"lighting-output":1}}], + "object-list-size": 3} diff --git a/zephyr/samples/profiles/b-ls/README.rst b/zephyr/samples/profiles/b-ls/README.rst index 363c8e4..2ac5896 100644 --- a/zephyr/samples/profiles/b-ls/README.rst +++ b/zephyr/samples/profiles/b-ls/README.rst @@ -58,4 +58,29 @@ Compile this sample for the `rpi_pico` board: Compile this sample for the `adafruit_grand_central_m4_express` board with - west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/ + west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ls/ + +Using the Shell +*************** + +The shell is available on some boards via virtual communication port: + + picocom --baud 115200 /dev/ttyACM0 + + Terminal ready + *** Booting Zephyr OS build v3.7.0 *** + [00:00:00.012,000] bacnet: BACnet Device: BACnet Lighting Supervisor (B-LS) + [00:00:00.012,000] bacnet: BACnet Stack Version 1.4.1 + [00:00:00.012,000] bacnet: BACnet Stack Max APDU: 1476 + uart:~$ + bacnet clear device devmem help history kernel net + rem resize retval shell stats + uart:~$ bacnet objects + {"object-list": [ + {"object-identifier":{"device":260126}}, + {"object-identifier":{"network-port":0}}, + {"object-identifier":{"lighting-output":1}}, + {"object-identifier":{"channel":1}}, + {"object-identifier":{"binary-lighting-output":1}}], + "object-list-size": 5} + diff --git a/zephyr/samples/profiles/b-sa/README.rst b/zephyr/samples/profiles/b-sa/README.rst index 793daa4..7f13e86 100644 --- a/zephyr/samples/profiles/b-sa/README.rst +++ b/zephyr/samples/profiles/b-sa/README.rst @@ -33,4 +33,26 @@ Compile this sample for the `rpi_pico` board: Compile this sample for the `adafruit_grand_central_m4_express` board with - west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/ + west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-sa/ + +Using the Shell +*************** + +The shell is available on some boards via virtual communication port: + + picocom --baud 115200 /dev/ttyACM0 + + Terminal ready + *** Booting Zephyr OS build v3.7.0 *** + [00:00:00.012,000] bacnet: BACnet Device: BACnet Smart Actuator (B-SA) + [00:00:00.012,000] bacnet: BACnet Stack Version 1.4.1 + [00:00:00.012,000] bacnet: BACnet Stack Max APDU: 1476 + uart:~$ + bacnet clear device devmem help history kernel net + rem resize retval shell stats + uart:~$ bacnet objects + {"object-list": [ + {"object-identifier":{"device":260124}}, + {"object-identifier":{"analog-output":1}}, + {"object-identifier":{"network-port":0}}], + "object-list-size": 3} diff --git a/zephyr/samples/profiles/b-ss/README.rst b/zephyr/samples/profiles/b-ss/README.rst index 1cccc1f..9364287 100644 --- a/zephyr/samples/profiles/b-ss/README.rst +++ b/zephyr/samples/profiles/b-ss/README.rst @@ -33,4 +33,26 @@ Compile this sample for the `rpi_pico` board: Compile this sample for the `adafruit_grand_central_m4_express` board with - west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/ + west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ss/ + +Using the Shell +*************** + +The shell is available on some boards via virtual communication port: + + picocom --baud 115200 /dev/ttyACM0 + + Terminal ready + *** Booting Zephyr OS build v3.7.0 *** + [00:00:00.012,000] bacnet: BACnet Device: BACnet Smart Sensor (B-SS) + [00:00:00.012,000] bacnet: BACnet Stack Version 1.4.1 + [00:00:00.012,000] bacnet: BACnet Stack Max APDU: 1476 + uart:~$ + bacnet clear device devmem help history kernel net + rem resize retval shell stats + uart:~$ bacnet objects + {"object-list": [ + {"object-identifier":{"device":4194303}}, + {"object-identifier":{"analog-input":1}}, + {"object-identifier":{"network-port":0}}], + "object-list-size": 3} diff --git a/zephyr/subsys/bacnet_shell/bacnet_shell_objects.c b/zephyr/subsys/bacnet_shell/bacnet_shell_objects.c index 621571c..605f24c 100644 --- a/zephyr/subsys/bacnet_shell/bacnet_shell_objects.c +++ b/zephyr/subsys/bacnet_shell/bacnet_shell_objects.c @@ -34,16 +34,19 @@ static int cmd_objects(const struct shell *sh, size_t argc, char **argv) (void)argc; (void)argv; - shell_print(sh, "List of BACnet Objects: [{"); + /* display the object-list as well formed JSON */ + shell_print(sh, "{\"%s\": [", bactext_property_name(PROP_OBJECT_LIST)); count = Device_Object_List_Count(); for (array_index = 1; array_index <= count; array_index++) { found = Device_Object_List_Identifier(array_index, &object_type, &instance); if (found) { - shell_print(sh, " \"%s-%u\"%c", bactext_object_type_name(object_type), - instance, (array_index == count) ? ' ' : ','); + shell_print(sh, "{\"%s\":{\"%s\":%u}}%s", + bactext_property_name(PROP_OBJECT_IDENTIFIER), + bactext_object_type_name(object_type), instance, + (array_index == count) ? "]," : ","); } } - shell_print(sh, "}] -- %d objects found", count); + shell_print(sh, "\"object-list-size\": %d}", count); return 0; }