You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
993 B

#!/bin/sh
MASTERFILE=./BUILD/NUCLEO_L073RZ/GCC_ARM-RELEASE/waveofhoney-mbed5.bin
# patterns
DEVICEEUI=ABBAABBAABBAABBA
APPEUI=ACCAACCAACCAACCA
APPKEY=ADDAADDAADDAADDAADDAADDAADDAADDA
if [ $# -ne 2 ]; then
echo "gen_images <master_binary> <devices_file>\n"
echo "devices file must be in the form :\n"
echo "dev1name:dev1eui:dev1appeui:dev1appkey"
echo "dev2name:dev2eui:dev2appeui:dev2appkey\n"
exit 1;
fi
MASTER=$1
DEVICES=$2
if [ ! -e $MASTER ]; then
echo "The master file $MASTER doesn't exists"
exit 1;
fi
if [ ! -e $DEVICES ]; then
echo "The devices file $DEVICES doesn't exists"
exit 1;
fi
for DEVICE in $(cat $DEVICES); do
name=$(echo $DEVICE | cut -d : -f 1)
deviceeui=$(echo $DEVICE | cut -d : -f 2)
appeui=$(echo $DEVICE | cut -d : -f 3)
appkey=$(echo $DEVICE | cut -d : -f 4)
echo $name
hexdump -ve '1/1 "%.2X"' $MASTERFILE | sed "s/$DEVICEEUI/$deviceeui/; s/$APPEUI/$appeui/; s/$APPKEY/$appkey/" | xxd -r -p > waveofhoney-${name}.bin
done
exit;