@@ -82,28 +82,23 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
8282
8383 // Generic Access Service setup.
8484
85- bleio_uuid_obj_t * generic_access_service_uuid = m_new_obj (bleio_uuid_obj_t );
86- generic_access_service_uuid -> base .type = & bleio_uuid_type ;
85+ bleio_uuid_obj_t * generic_access_service_uuid = mp_obj_malloc (bleio_uuid_obj_t , & bleio_uuid_type );
8786 common_hal_bleio_uuid_construct (generic_access_service_uuid , 0x1800 , NULL );
8887
89- bleio_uuid_obj_t * device_name_characteristic_uuid = m_new_obj (bleio_uuid_obj_t );
90- device_name_characteristic_uuid -> base .type = & bleio_uuid_type ;
88+ bleio_uuid_obj_t * device_name_characteristic_uuid = mp_obj_malloc (bleio_uuid_obj_t , & bleio_uuid_type );
9189 common_hal_bleio_uuid_construct (device_name_characteristic_uuid , 0x2A00 , NULL );
9290
93- bleio_uuid_obj_t * appearance_characteristic_uuid = m_new_obj (bleio_uuid_obj_t );
94- appearance_characteristic_uuid -> base .type = & bleio_uuid_type ;
91+ bleio_uuid_obj_t * appearance_characteristic_uuid = mp_obj_malloc (bleio_uuid_obj_t , & bleio_uuid_type );
9592 common_hal_bleio_uuid_construct (appearance_characteristic_uuid , 0x2A01 , NULL );
9693
9794 // Not implemented:
9895 // Peripheral Preferred Connection Parameters
9996 // Central Address Resolution
10097
101- bleio_service_obj_t * generic_access_service = m_new_obj (bleio_service_obj_t );
102- generic_access_service -> base .type = & bleio_service_type ;
98+ bleio_service_obj_t * generic_access_service = mp_obj_malloc (bleio_service_obj_t , & bleio_service_type );
10399 common_hal_bleio_service_construct (generic_access_service , generic_access_service_uuid , false);
104100
105- adapter -> device_name_characteristic = m_new_obj (bleio_characteristic_obj_t );
106- adapter -> device_name_characteristic -> base .type = & bleio_characteristic_type ;
101+ adapter -> device_name_characteristic = mp_obj_malloc (bleio_characteristic_obj_t , & bleio_characteristic_type );
107102
108103 char generic_name [] = { 'C' , 'I' , 'R' , 'C' , 'U' , 'I' , 'T' , 'P' , 'Y' , 'n' , 'n' , 'n' , 'n' };
109104 mp_buffer_info_t generic_name_bufinfo = {
@@ -132,8 +127,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
132127 .len = sizeof (zero_16 ),
133128 };
134129
135- adapter -> appearance_characteristic = m_new_obj (bleio_characteristic_obj_t );
136- adapter -> appearance_characteristic -> base .type = & bleio_characteristic_type ;
130+ adapter -> appearance_characteristic = mp_obj_malloc (bleio_characteristic_obj_t , & bleio_characteristic_type );
137131
138132 common_hal_bleio_characteristic_construct (
139133 adapter -> appearance_characteristic ,
@@ -151,20 +145,16 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
151145
152146 // Generic Attribute Service setup.
153147
154- bleio_uuid_obj_t * generic_attribute_service_uuid = m_new_obj (bleio_uuid_obj_t );
155- generic_attribute_service_uuid -> base .type = & bleio_uuid_type ;
148+ bleio_uuid_obj_t * generic_attribute_service_uuid = mp_obj_malloc (bleio_uuid_obj_t , & bleio_uuid_type );
156149 common_hal_bleio_uuid_construct (generic_attribute_service_uuid , 0x1801 , NULL );
157150
158- bleio_uuid_obj_t * service_changed_characteristic_uuid = m_new_obj (bleio_uuid_obj_t );
159- service_changed_characteristic_uuid -> base .type = & bleio_uuid_type ;
151+ bleio_uuid_obj_t * service_changed_characteristic_uuid = mp_obj_malloc (bleio_uuid_obj_t , & bleio_uuid_type );
160152 common_hal_bleio_uuid_construct (service_changed_characteristic_uuid , 0x2A05 , NULL );
161153
162- bleio_service_obj_t * generic_attribute_service = m_new_obj (bleio_service_obj_t );
163- generic_attribute_service -> base .type = & bleio_service_type ;
154+ bleio_service_obj_t * generic_attribute_service = mp_obj_malloc (bleio_service_obj_t , & bleio_service_type );
164155 common_hal_bleio_service_construct (generic_attribute_service , generic_attribute_service_uuid , false);
165156
166- adapter -> service_changed_characteristic = m_new_obj (bleio_characteristic_obj_t );
167- adapter -> service_changed_characteristic -> base .type = & bleio_characteristic_type ;
157+ adapter -> service_changed_characteristic = mp_obj_malloc (bleio_characteristic_obj_t , & bleio_characteristic_type );
168158
169159 uint32_t zero_32 = 0 ;
170160 mp_buffer_info_t zero_32_value = {
@@ -416,8 +406,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s
416406 bt_addr_t addr ;
417407 hci_check_error (hci_read_bd_addr (& addr ));
418408
419- bleio_address_obj_t * address = m_new_obj (bleio_address_obj_t );
420- address -> base .type = & bleio_address_type ;
409+ bleio_address_obj_t * address = mp_obj_malloc (bleio_address_obj_t , & bleio_address_type );
421410
422411 common_hal_bleio_address_construct (address , addr .val , BT_ADDR_LE_PUBLIC );
423412 return address ;
0 commit comments