nrf5/modules: Shuffle order of typedef in ubluepy header. Adding service pointer in characteristic object. Adding peripheral pointer to the service structure. When populated, the characteristic would get access to conn_handle and service handle through pointers. Also service would get access to peripheral instance.

This commit is contained in:
Glenn Ruben Bakke 2017-02-18 01:19:43 +01:00
parent e0fc8b88c1
commit 292c15bf1a

View File

@ -61,6 +61,7 @@ s.addCharacteristic(c)
p = Peripheral()
p.setConnectionHandler(event_handler)
p.advertise(device_name="micr", services=[s])
*/
#include "py/obj.h"
@ -85,27 +86,6 @@ typedef struct _ubluepy_uuid_obj_t {
uint8_t uuid_vs_idx;
} ubluepy_uuid_obj_t;
typedef struct _ubluepy_service_obj_t {
mp_obj_base_t base;
uint16_t handle;
uint8_t type;
ubluepy_uuid_obj_t * p_uuid;
} ubluepy_service_obj_t;
typedef struct _ubluepy_characteristic_obj_t {
mp_obj_base_t base;
uint16_t handle;
ubluepy_uuid_obj_t * p_uuid;
uint16_t service_handle;
uint16_t user_desc_handle;
uint16_t cccd_handle;
uint16_t sccd_handle;
} ubluepy_characteristic_obj_t;
typedef struct _ubluepy_delegate_obj_t {
mp_obj_base_t base;
} ubluepy_delegate_obj_t;
typedef struct _ubluepy_peripheral_obj_t {
mp_obj_base_t base;
uint16_t conn_handle;
@ -114,6 +94,29 @@ typedef struct _ubluepy_peripheral_obj_t {
mp_obj_t conn_handler;
} ubluepy_peripheral_obj_t;
typedef struct _ubluepy_service_obj_t {
mp_obj_base_t base;
uint16_t handle;
uint8_t type;
ubluepy_uuid_obj_t * p_uuid;
ubluepy_peripheral_obj_t * p_periph;
} ubluepy_service_obj_t;
typedef struct _ubluepy_characteristic_obj_t {
mp_obj_base_t base;
uint16_t handle;
ubluepy_uuid_obj_t * p_uuid;
uint16_t service_handle;
uint16_t user_desc_handle;
uint16_t cccd_handle;
uint16_t sccd_handle;
ubluepy_service_obj_t * p_service;
} ubluepy_characteristic_obj_t;
typedef struct _ubluepy_delegate_obj_t {
mp_obj_base_t base;
} ubluepy_delegate_obj_t;
typedef struct _ubluepy_advertise_data_t {
uint8_t * p_device_name;
uint8_t device_name_len;