@@ -82,28 +82,23 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
82
82
83
83
// Generic Access Service setup.
84
84
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 );
87
86
common_hal_bleio_uuid_construct (generic_access_service_uuid , 0x1800 , NULL );
88
87
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 );
91
89
common_hal_bleio_uuid_construct (device_name_characteristic_uuid , 0x2A00 , NULL );
92
90
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 );
95
92
common_hal_bleio_uuid_construct (appearance_characteristic_uuid , 0x2A01 , NULL );
96
93
97
94
// Not implemented:
98
95
// Peripheral Preferred Connection Parameters
99
96
// Central Address Resolution
100
97
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 );
103
99
common_hal_bleio_service_construct (generic_access_service , generic_access_service_uuid , false);
104
100
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 );
107
102
108
103
char generic_name [] = { 'C' , 'I' , 'R' , 'C' , 'U' , 'I' , 'T' , 'P' , 'Y' , 'n' , 'n' , 'n' , 'n' };
109
104
mp_buffer_info_t generic_name_bufinfo = {
@@ -132,8 +127,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
132
127
.len = sizeof (zero_16 ),
133
128
};
134
129
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 );
137
131
138
132
common_hal_bleio_characteristic_construct (
139
133
adapter -> appearance_characteristic ,
@@ -151,20 +145,16 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
151
145
152
146
// Generic Attribute Service setup.
153
147
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 );
156
149
common_hal_bleio_uuid_construct (generic_attribute_service_uuid , 0x1801 , NULL );
157
150
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 );
160
152
common_hal_bleio_uuid_construct (service_changed_characteristic_uuid , 0x2A05 , NULL );
161
153
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 );
164
155
common_hal_bleio_service_construct (generic_attribute_service , generic_attribute_service_uuid , false);
165
156
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 );
168
158
169
159
uint32_t zero_32 = 0 ;
170
160
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
416
406
bt_addr_t addr ;
417
407
hci_check_error (hci_read_bd_addr (& addr ));
418
408
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 );
421
410
422
411
common_hal_bleio_address_construct (address , addr .val , BT_ADDR_LE_PUBLIC );
423
412
return address ;
@@ -490,7 +479,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
490
479
self -> scan_results = shared_module_bleio_new_scanresults (buffer_size , prefixes , prefix_length , minimum_rssi );
491
480
492
481
// size_t max_packet_size = extended ? BLE_GAP_SCAN_BUFFER_EXTENDED_MAX_SUPPORTED : BLE_GAP_SCAN_BUFFER_MAX;
493
- // uint8_t *raw_data = m_malloc(sizeof(ble_data_t) + max_packet_size, false );
482
+ // uint8_t *raw_data = m_malloc(sizeof(ble_data_t) + max_packet_size);
494
483
// ble_data_t * sd_data = (ble_data_t *) raw_data;
495
484
// self->scan_results->common_hal_data = sd_data;
496
485
// sd_data->len = max_packet_size;
0 commit comments