nrf5/modules: Updating ubluepy module header usage example. Correcting enum for UUID types to start index from 1. Expanding advertisment data structure to also include service list members.

This commit is contained in:
Glenn Ruben Bakke 2017-02-12 15:14:41 +01:00
parent 90523d6ae0
commit 2d72fe8518
1 changed files with 9 additions and 5 deletions

View File

@ -37,13 +37,14 @@ p.advertise(device_name="MicroPython")
DB setup: DB setup:
from ubluepy import Service, Characteristic, UUID from ubluepy import Service, Characteristic, UUID, Peripheral
u0 = UUID("6e400001-b5a3-f393-e0a9-e50e24dcca9e") u0 = UUID("6e400001-b5a3-f393-e0a9-e50e24dcca9e")
s = Service(u0) s = Service(u0)
u1 = UUID("6e400002-b5a3-f393-e0a9-e50e24dcca9e") u1 = UUID("6e400002-b5a3-f393-e0a9-e50e24dcca9e")
c = Characteristic(u1) c = Characteristic(u1)
s.addCharacteristic(c) s.addCharacteristic(c)
p = Peripheral()
p.advertise(device_name="MicroPython", services=[s])
*/ */
#include "py/obj.h" #include "py/obj.h"
@ -52,7 +53,7 @@ extern const mp_obj_type_t ubluepy_uuid_type;
extern const mp_obj_type_t ubluepy_service_type; extern const mp_obj_type_t ubluepy_service_type;
typedef enum { typedef enum {
UBLUEPY_UUID_16_BIT, UBLUEPY_UUID_16_BIT = 1,
UBLUEPY_UUID_128_BIT UBLUEPY_UUID_128_BIT
} ubluepy_uuid_type_t; } ubluepy_uuid_type_t;
@ -86,8 +87,11 @@ typedef struct _ubluepy_characteristic_obj_t {
} ubluepy_characteristic_obj_t; } ubluepy_characteristic_obj_t;
typedef struct _ubluepy_advertise_data_t { typedef struct _ubluepy_advertise_data_t {
uint8_t * p_device_name; uint8_t * p_device_name;
uint8_t device_name_len; uint8_t device_name_len;
mp_obj_t * p_services;
uint8_t num_of_services;
} ubluepy_advertise_data_t; } ubluepy_advertise_data_t;
#endif // UBLUEPY_H__ #endif // UBLUEPY_H__