Reverse mac address layout in mac changing scene (bad ble)

This commit is contained in:
yocvito
2023-01-25 23:44:47 +01:00
parent df4d512f7d
commit d518f9fa5b
@@ -2,6 +2,16 @@
#define TAG "BadBleConfigMac"
static uint8_t* reverse_mac_addr(uint8_t* mac) {
uint8_t tmp;
for(int i = 0; i < 3; i++) {
tmp = mac[i];
mac[i] = mac[5 - i];
mac[5 - i] = tmp;
}
return mac;
}
void bad_ble_scene_config_mac_byte_input_callback(void* context) {
BadBleApp* bad_ble = context;
@@ -19,7 +29,7 @@ void bad_ble_scene_config_mac_on_enter(void* context) {
bad_ble_scene_config_mac_byte_input_callback,
NULL,
bad_ble,
bad_ble->mac,
reverse_mac_addr(bad_ble->mac),
GAP_MAC_ADDR_SIZE);
view_dispatcher_switch_to_view(bad_ble->view_dispatcher, BadBleAppViewConfigMac);
}
@@ -30,7 +40,7 @@ bool bad_ble_scene_config_mac_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == BadBleAppCustomEventByteInputDone) {
bt_set_profile_mac_address(bad_ble->bt, bad_ble->mac);
bt_set_profile_mac_address(bad_ble->bt, reverse_mac_addr(bad_ble->mac));
scene_manager_previous_scene(bad_ble->scene_manager);
consumed = true;
}