Developing lightweight computation at the DSG edge

Commit 4f937eda authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Fix qmp_get_dec_node_id()

In some corner cases, function qmp_get_dec_node_id() would throw an
error when asking for the MAC address of a missing interface, and then
printing the LSBs in decimal number.
Signed-off-by: default avatarRoger Pueyo Centelles <>
parent 5f0bebe4
...@@ -309,15 +309,51 @@ qmp_tac() { ...@@ -309,15 +309,51 @@ qmp_tac() {
} }
qmp_get_dec_node_id() { qmp_get_dec_node_id() {
PRIMARY_MESH_DEVICE="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')" qmp_log "Getting decimal node id"
LSB_PRIM_MAC="$( qmp_get_mac_for_dev $PRIMARY_MESH_DEVICE | awk -F':' '{print $6}' )"
local DEVICE_ID=""
if qmp_uci_test qmp.node.device_id; then local PRIMARY_DEVICE=""
DEVICE_ID="$(uci get qmp.node.device_id)"
elif ! [ -z "$PRIMARY_MESH_DEVICE" ] ; then if qmp_uci_test qmp.node.device_id; then
DEVICE_ID=$LSB_PRIM_MAC qmp_log "Getting device_id from qMp config"
fi DEVICE_ID="$(uci get qmp.node.device_id)"
echo $(printf %d 0x$DEVICE_ID) qmp_log "Device id: ${DEVICE_ID}"
if [ -z "$DEVICE_ID" ] && qmp_uci_test qmp.node.primary_device; then
qmp_log "Getting primary_device from qMp config"
local QMPCONFIG_PRIMARY_DEVICE="$(uci get qmp.node.primary_device)"
if [ -e "/sys/class/net/$QMPCONFIG_PRIMARY_DEVICE" ]; then
qmp_log "Primary device found: ${PRIMARY_DEVICE}"
qmp_log "Primary device not found: ${QMPCONFIG_PRIMARY_DEVICE}"
if [ -z "$DEVICE_ID" ] && [ -z "$PRIMARY_DEVICE" ] && \
qmp_uci_test qmp.interfaces.mesh_devices; then
qmp_log "Getting first mesh device from qMp config"
qmp_log "Found mesh devices: $(uci get qmp.interfaces.mesh_devices)"
local PRIMARY_DEVICE="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
qmp_log "Mesh primary device: $PRIMARY_DEVICE"
if [ -n "$PRIMARY_DEVICE" ]; then
qmp_log "Getting MAC for device $PRIMARY_DEVICE"
LSB_PRIM_MAC="$( qmp_get_mac_for_dev $PRIMARY_DEVICE | awk -F':' '{print $6}' )"
qmp_log "Primary device LSBs: $LSB_PRIM_MAC"
if [ -n $LSB_PRIM_MAC ]; then
if [ -n "$DEVICE_ID" ]; then
qmp_log "Decimal node id: $(printf %d 0x$DEVICE_ID)"
echo "$(printf %d 0x$DEVICE_ID)"
qmp_log "Decimal node id not found, returning 0xABCD."
echo "$(printf %d 0xABCD)"
} }
# Returns the prefix /XX from netmask # Returns the prefix /XX from netmask
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment