8000 How get BLE mac address wasp-os pinetime watch · Issue #7944 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
How get BLE mac address wasp-os pinetime watch #7944
Open
@faustolnx

Description

@faustolnx

Hello,
how get ble mac address in wasp-os whit pinetime hardware?

I try this function in C

STATIC mp_obj_t peripheral_get_mac_address(void) {

ble_drv_addr_t local_addr;
ble_drv_address_get(&local_addr);
vstr_t vstr;
vstr_init(&vstr, 17);

vstr_printf(&vstr, ""HEX2_FMT":"HEX2_FMT":"HEX2_FMT":" \
                     HEX2_FMT":"HEX2_FMT":"HEX2_FMT"",
            local_addr.addr[5], local_addr.addr[4], local_addr.addr[3],
            local_addr.addr[2], local_addr.addr[1], local_addr.addr[0]);

mp_obj_t mac_str = mp_obj_new_str(vstr.buf, vstr.len);

vstr_clear(&vstr);

return mac_str;

}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ubluepy_peripheral_get_mac_address_obj, peripheral_get_mac_address);

STATIC const mp_rom_map_elem_t ubluepy_peripheral_locals_dict_table[] = {
#if MICROPY_PY_UBLUEPY_PERIPHERAL

{ MP_ROM_QSTR(MP_QSTR_advertise),              MP_ROM_PTR(&ubluepy_peripheral_advertise_obj) },
{ MP_ROM_QSTR(MP_QSTR_advertise_stop),         MP_ROM_PTR(&ubluepy_peripheral_advertise_stop_obj) },
{ MP_ROM_QSTR(MP_QSTR_disconnect),             MP_ROM_PTR(&ubluepy_peripheral_disconnect_obj) },
{ MP_ROM_QSTR(MP_QSTR_addService),             MP_ROM_PTR(&ubluepy_peripheral_add_service_obj) },
{ MP_ROM_QSTR(MP_QSTR_get_mac_address),        MP_ROM_PTR(&ubluepy_peripheral_get_mac_address_obj) },

#endif
};

in MicroPhyton
i call the function in this way
macaddress=""
p = Peripheral()
macaddress=p.get_mac_address()

but i get this error: Can't convert from none type to int

thanks for your help

Fausto

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-infoThis issue needs more information to be resolvableport-nrf

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0