Set iBeacon using macro
Hi everyone,
I tried to set MetaMotion R as a beacon using the macro. It is working perfectly but when the MetaMotion R battery die and I recharge it again the macro not working anymore and I need to set it as a beacon again. Is there any way to make MetaMotion R working as a beacon even after the power off and on?
MetaMotion R hardware revision is 0.4 and firmware revision is 1.5.0
My Python code below:
def macro(mac):
d = connect_2_bt(mac)
if d is not None:
try:
# Start recording the macro
libmetawear.mbl_mw_macro_record(d.board, 1)
# Set major number to 31415
libmetawear.mbl_mw_ibeacon_set_major(d.board, 31415)
# Set minor number to 9265
libmetawear.mbl_mw_ibeacon_set_minor(d.board, 9265)
# Enable ibeacon mode
libmetawear.mbl_mw_ibeacon_enable(d.board)
except RuntimeError as err:
print('Unable to set Macro for ({}) \n Error message: {}'.format(mac, err))
finally:
d.disconnect()
# Bluetooth connection function
def connect_2_bt(mac):
print("Searching for device ({})...".format(mac))
try:
device = MetaWear(mac)
device.connect()
print("Connected to ({})".format(device.address))
return device
except Exception as err:
print('Unable to connect to the node MAC({}) \n Error message: {}'.format(mac, err))
return None
Comments
Yes, the macro will get this done. If you aren't successful it is because you programmed the macro wrong. I can already tell this is the issue as your code is missing the end_macro command.
Thank you @Laura
I will try to add "end macro" function and check
Hi @Laura,
I end the macro but I still facing the same problem.
please check my code below:
Take a look at the swift examples for this and make sure you are doing the same thing in python.
Also if you read our tutorials, it says you have to disconnect and then just scan the metawear to make sure it worked.
Hi @Laura
Unfortunately, I'm not a SWIFT developer and I didn't deal with it before, but I tried my best and updated my code according to the SWIFT example for beacons but it still the same issue.
I hope you can help us to solve this problem.
my new code:
@Laura hello!
You need to make it a boot macro: libmetawear.mbl_mw_macro_record(d.board, 0) <-- must be 0
Hi @Laura
As mentioned in documentation (1) to run the macro on boot not (0) as you mentioned
you can check the documentation at this link
https://github.com/mbientlab/MetaWear-SDK-Python/blob/master/docs/source/macro.rst
anyway I was succeeded to set iBeacon to run on the boot
this my working code in case anybody faces the same problem can use my code
Awesome, thanks for the update @qudor.
Totally my bad for getting them mixed up. Thank you for pointing that out.