How to set the scan response
I've been trying without success the setting of the scan response in my MMR+ (firmware 1.4.4), according to the documentation of the SDK that could do it in a similar way like changing the name, because those two functions (
mbl_mw_settings_set_scan_response) have the same type of parameters.
This is my code based on the macro_setup.py example:
from __future__ import print_function from mbientlab.metawear import MetaWear, libmetawear, parse_value, create_voidp_int, create_voidp from mbientlab.metawear.cbindings import * from threading import Event import platform import sys device = MetaWear(sys.argv) device.connect() print("Connected to " + device.address) e = Event() print("Configuring device") signal= libmetawear.mbl_mw_switch_get_state_data_signal(device.board) # Start macro recording libmetawear.mbl_mw_macro_record(device.board, 1) arr = (c_uint8 * 8)(*([0x42, 0x72, 0x61, 0x63, 0x65, 0x6c, 0x65, 0x74])) libmetawear.mbl_mw_settings_set_device_name(device.board, arr, 8) scan = (c_uint8 * 8)(*([0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01])) libmetawear.mbl_mw_settings_set_scan_response(device.board, scan, 8) # Setup comparators - the first when the button is not pressed and the second when it's pressed not_pressed = create_voidp(lambda fn: libmetawear.mbl_mw_dataprocessor_comparator_create(signal, ComparatorOperation.EQ, 0.0, None, fn), resource = "not_pressed", event = e) pressed = create_voidp(lambda fn: libmetawear.mbl_mw_dataprocessor_comparator_create(signal, ComparatorOperation.EQ, 1.0, None, fn), resource = "pressed", event = e) # LED is OFF when the button is not pressed libmetawear.mbl_mw_event_record_commands(not_pressed) libmetawear.mbl_mw_led_stop_and_clear(device.board) create_voidp_int(lambda fn: libmetawear.mbl_mw_event_end_record(not_pressed, None, fn), event = e) # LED is ON when the button is pressed and the motor runs pattern= LedPattern(pulse_duration_ms=1000, high_time_ms=500, high_intensity=16, low_intensity=16, repeat_count=Const.LED_REPEAT_INDEFINITELY) libmetawear.mbl_mw_event_record_commands(pressed) libmetawear.mbl_mw_led_write_pattern(device.board, byref(pattern), LedColor.BLUE) libmetawear.mbl_mw_led_play(device.board) # Run motor at 50% strength for 500 ms when the button is pressed libmetawear.mbl_mw_haptic_start_motor(device.board, 50.0, 500); create_voidp_int(lambda fn: libmetawear.mbl_mw_event_end_record(pressed, None, fn), event = e) # End macro recording create_voidp_int(lambda fn: libmetawear.mbl_mw_macro_end_record(device.board, None, fn), event = e) print("Resetting device") device.on_disconnect = lambda status: e.set() libmetawear.mbl_mw_debug_reset(device.board) e.wait()
Changing the name is working, because it advertises like "Bracelet", but I cannot find the scan response using the nRF connect app.
The goal with this it will be to change the scan response from time to time according some events.
What do you suggest me? Is it really possible what I'm trying to do?
Thanks for your answers!