I am using a pi as a beacon and I have implemented EddyStone beacon URL. I can broadcast short URLs with no issue but now I want to broadcast a simple message which is stored as a string in a text file.
I would like to read the text file and broadcast it when the beacon is on. Can anyone help me with this? thanks in advance. Here's my code:
import os
on_bluetooth = os.system("sudo hciconfig hci0 up") # bluetooth on
discoverable_on = os.system("sudo hciconfig hci0 leadv 3") # discoverable on but not connectable
cond = True
while cond:
try:
fh = open('/home/Desktop/message.txt')
cond = False
except:
print('File does not exist.')
continue
for line in fh:
line = line.rstrip()
text = line
print("The message is:", text)
message = os.system("sudo hcitool -i hci0 cmd 0x08 0x0008 <insert text variable here>") # broadcast message