mirror of
https://github.com/meshtastic/python.git
synced 2026-01-21 06:07:58 -05:00
suggested fix from MitchConner912 for not converting mac address more than once
This commit is contained in:
@@ -249,4 +249,5 @@ def test_findPorts_when_none_found(patch_comports):
|
||||
def test_convert_mac_addr():
|
||||
"""Test convert_mac_addr()"""
|
||||
assert convert_mac_addr('/c0gFyhb') == 'fd:cd:20:17:28:5b'
|
||||
assert convert_mac_addr('fd:cd:20:17:28:5b') == 'fd:cd:20:17:28:5b'
|
||||
assert convert_mac_addr('') == ''
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import traceback
|
||||
from queue import Queue
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import base64
|
||||
import time
|
||||
@@ -238,5 +239,7 @@ def convert_mac_addr(val):
|
||||
val - base64 encoded value (ex: '/c0gFyhb'))
|
||||
returns: a string formatted like a mac address (ex: 'fd:cd:20:17:28:5b')
|
||||
"""
|
||||
val_as_bytes = base64.b64decode(val)
|
||||
return hexstr(val_as_bytes)
|
||||
if not re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", val):
|
||||
val_as_bytes = base64.b64decode(val)
|
||||
return hexstr(val_as_bytes)
|
||||
return val
|
||||
|
||||
Reference in New Issue
Block a user