-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
bugSomething isn't workingSomething isn't working
Description
It took me some time to get the file /BLE-Scanner_ESP32/BLE-Scanner/ble-manufacturer-list.h right.
I had to remove \ and " from strings and keep the right format.
This is ble-manufacturer-list.h that works for me:
/*
updated with ./update-manufacturer-list_yaml.sh
*/
#ifndef BLE_MANUFACTURER_LIST_H
#define BLE_MANUFACTURER_LIST_H
{ 0x0CCF , " Shenzhen CESI Information Techn" },
{ 0x0CCE , " SENOSPACE LLC" },
....
{ 0x0000 , " Ericsson AB" },
};
#endif // BLE_MANUFACTURER_LIST_H
I used this bash file :
#!/bin/bash
# Input YAML file and temporary file name
INPUT_FILE="company_identifiers.yaml"
TMP_FILE="tmp_formatted_data.txt"
OUTPUT_FILE="../../BLE-Scanner/ble-manufacturer-list.h"
URL="https://bitbucket.org/bluetooth-SIG/public/src/main/company_identifiers/company_identifiers.yaml"
# was : "https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/CompanyIdentfiers - CSV.csv"
#wget $URL
cat <<EOM
As the offical file with all assigned manufacurer IDs is prevented
to be automatically downloaded, this has to be done manually. So,
please download the yaml file from
$URL
and store the yaml as
$INPUT_FILE
Hit return when done, otherwise cancel with <Ctrl-C>
EOM
read
# Process YAML file and generate temporary formatted content
cat > "$TMP_FILE" <<EOM
/*
updated with $0
$(date)
*/
EOM
# Add include guards to the temporary file
echo "#ifndef BLE_MANUFACTURER_LIST_H" >> "$TMP_FILE"
echo "#define BLE_MANUFACTURER_LIST_H" >> "$TMP_FILE"
#echo "const char* company_identifiers[] = {" >> "$TMP_FILE"
# Process the YAML file using awk with proper escaping of double quotes
while IFS=":," read -r key value _; do
if [[ "$key" =~ value ]]; then
hex=$(echo "$value" | tr -d ' ')
printf "{ %s , " "$hex" >> "$TMP_FILE"
elif [[ "$key" =~ name ]]; then
name=$(echo "$value" | tr -d "\"'#\\/,()" | head -c 32)
if [[ -z "$name" ]]; then
name="missing_name"
fi
printf "\"%s\" },\n" "$name" >> "$TMP_FILE"
fi
done < "$INPUT_FILE"
# Close the include guards in the temporary file
echo "};" >> "$TMP_FILE"
echo "#endif // BLE_MANUFACTURER_LIST_H" >> "$TMP_FILE"
# Move the temporary file to the output file
mv "$TMP_FILE" "$OUTPUT_FILE"
# Count the number of entries written to the C header file
ITEMS=$(awk '/value:/' "$INPUT_FILE" | wc -l)
echo "Written $ITEMS entries to $OUTPUT_FILE -- recompile the sketch. Close arduino IDE and reopen ../../BLE-Scanner.ino"
# Additional code to read the YAML and rewrite in desired format
Paxy
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working