Skip to content

Commit 939370b

Browse files
committed
Update pouch revision
This brings in a change that renames the Golioth BLE GATT library to Pouch GATT, and updates the references in this repo to match. Signed-off-by: Sam Friedman <sam@golioth.io>
1 parent 3b854fd commit 939370b

13 files changed

Lines changed: 75 additions & 83 deletions

File tree

gateway/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ CONFIG_MAIN_STACK_SIZE=2048
3939
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
4040

4141
# Pouch BLE GATT Transport
42-
CONFIG_POUCH_TRANSPORT_BLE_GATT_COMMON=y
42+
CONFIG_POUCH_TRANSPORT_GATT_COMMON=y
4343

4444
CONFIG_ZVFS_EVENTFD_MAX=11

gateway/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <golioth/gateway.h>
1515
#include <samples/common/sample_credentials.h>
1616

17-
#include <pouch/transport/ble_gatt/common/types.h>
17+
#include <pouch/transport/gatt/common/types.h>
1818

1919
#include <pouch_gateway/bt/connect.h>
2020
#include <pouch_gateway/bt/scan.h>
@@ -190,7 +190,7 @@ void pouch_gateway_bt_finished(struct bt_conn *conn)
190190
int main(void)
191191
{
192192
LOG_INF("Gateway Version: " STRINGIFY(GIT_DESCRIBE));
193-
LOG_INF("Pouch BLE Transport Protocol Version: %d", GOLIOTH_BLE_GATT_VERSION);
193+
LOG_INF("Pouch BLE Transport Protocol Version: %d", POUCH_GATT_VERSION);
194194

195195
connect_to_cloud();
196196

include/pouch_gateway/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct pouch_gateway_node_info
4242
struct pouch_gateway_downlink_context *downlink_ctx;
4343
void *downlink_scratch;
4444
void *server_cert_scratch;
45-
struct golioth_ble_gatt_packetizer *packetizer;
45+
struct pouch_gatt_packetizer *packetizer;
4646
struct pouch_gateway_uplink *uplink;
4747
struct pouch_gateway_device_cert_context *device_cert_ctx;
4848
struct pouch_gateway_server_cert_context *server_cert_ctx;

lib/bt/cert.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <zephyr/bluetooth/conn.h>
1111
#include <zephyr/bluetooth/gatt.h>
1212

13-
#include <pouch/transport/ble_gatt/common/packetizer.h>
13+
#include <pouch/transport/gatt/common/packetizer.h>
1414

1515
#include <pouch_gateway/bt/cert.h>
1616
#include <pouch_gateway/bt/connect.h>
@@ -46,7 +46,7 @@ static void server_cert_cleanup(struct bt_conn *conn)
4646

4747
if (node->packetizer)
4848
{
49-
golioth_ble_gatt_packetizer_finish(node->packetizer);
49+
pouch_gatt_packetizer_finish(node->packetizer);
5050
node->packetizer = NULL;
5151
}
5252
}
@@ -72,8 +72,7 @@ static uint8_t server_cert_read_cb(struct bt_conn *conn,
7272
bool is_first = false;
7373
bool is_last = false;
7474
const void *payload = NULL;
75-
ssize_t payload_len =
76-
golioth_ble_gatt_packetizer_decode(data, length, &payload, &is_first, &is_last);
75+
ssize_t payload_len = pouch_gatt_packetizer_decode(data, length, &payload, &is_first, &is_last);
7776
if (payload_len < 0)
7877
{
7978
LOG_ERR("Failed to decode BLE GATT %s (err %d)", "server cert", (int) payload_len);
@@ -140,8 +139,7 @@ static uint8_t device_cert_read_cb(struct bt_conn *conn,
140139
bool is_first = false;
141140
bool is_last = false;
142141
const void *payload = NULL;
143-
ssize_t payload_len =
144-
golioth_ble_gatt_packetizer_decode(data, length, &payload, &is_first, &is_last);
142+
ssize_t payload_len = pouch_gatt_packetizer_decode(data, length, &payload, &is_first, &is_last);
145143
if (payload_len < 0)
146144
{
147145
LOG_ERR("Failed to decode BLE GATT %s (err %d)", "device cert", (int) payload_len);
@@ -198,12 +196,12 @@ static int write_server_cert_characteristic(struct bt_conn *conn)
198196
}
199197

200198
size_t len = mtu - POUCH_GATEWAY_BT_ATT_OVERHEAD;
201-
enum golioth_ble_gatt_packetizer_result ret =
202-
golioth_ble_gatt_packetizer_get(node->packetizer, node->server_cert_scratch, &len);
199+
enum pouch_gatt_packetizer_result ret =
200+
pouch_gatt_packetizer_get(node->packetizer, node->server_cert_scratch, &len);
203201

204-
if (GOLIOTH_BLE_GATT_PACKETIZER_ERROR == ret)
202+
if (POUCH_GATT_PACKETIZER_ERROR == ret)
205203
{
206-
ret = golioth_ble_gatt_packetizer_error(node->packetizer);
204+
ret = pouch_gatt_packetizer_error(node->packetizer);
207205
LOG_ERR("Error getting %s data %d", "server cert", ret);
208206
return ret;
209207
}
@@ -263,25 +261,25 @@ static void write_response_cb(struct bt_conn *conn,
263261
}
264262
}
265263

266-
static enum golioth_ble_gatt_packetizer_result server_cert_fill_cb(void *dst,
267-
size_t *dst_len,
268-
void *user_arg)
264+
static enum pouch_gatt_packetizer_result server_cert_fill_cb(void *dst,
265+
size_t *dst_len,
266+
void *user_arg)
269267
{
270268
bool last = false;
271269

272270
int ret = pouch_gateway_server_cert_get_data(user_arg, dst, dst_len, &last);
273271
if (-EAGAIN == ret)
274272
{
275273
LOG_DBG("Awaiting additional %s data from cloud", "server cert");
276-
return GOLIOTH_BLE_GATT_PACKETIZER_MORE_DATA;
274+
return POUCH_GATT_PACKETIZER_MORE_DATA;
277275
}
278276
if (ret < 0)
279277
{
280278
*dst_len = 0;
281-
return GOLIOTH_BLE_GATT_PACKETIZER_ERROR;
279+
return POUCH_GATT_PACKETIZER_ERROR;
282280
}
283281

284-
return last ? GOLIOTH_BLE_GATT_PACKETIZER_NO_MORE_DATA : GOLIOTH_BLE_GATT_PACKETIZER_MORE_DATA;
282+
return last ? POUCH_GATT_PACKETIZER_NO_MORE_DATA : POUCH_GATT_PACKETIZER_MORE_DATA;
285283
}
286284

287285
static void gateway_server_cert_write_start(struct bt_conn *conn)
@@ -307,7 +305,7 @@ static void gateway_server_cert_write_start(struct bt_conn *conn)
307305

308306
node->server_cert_ctx = pouch_gateway_server_cert_start();
309307
node->packetizer =
310-
golioth_ble_gatt_packetizer_start_callback(server_cert_fill_cb, node->server_cert_ctx);
308+
pouch_gatt_packetizer_start_callback(server_cert_fill_cb, node->server_cert_ctx);
311309

312310
write_server_cert_characteristic(conn);
313311
}

lib/bt/connect.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <zephyr/bluetooth/uuid.h>
1212
#include <zephyr/sys/util.h>
1313

14-
#include <pouch/transport/ble_gatt/common/uuids.h>
14+
#include <pouch/transport/gatt/common/uuids.h>
1515

1616
#include <pouch_gateway/types.h>
1717
#include <pouch_gateway/bt/connect.h>
@@ -24,17 +24,14 @@
2424
LOG_MODULE_REGISTER(connect);
2525

2626
static const struct bt_uuid_128 golioth_svc_uuid_128 =
27-
BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_SVC_VAL_128);
28-
static const struct bt_uuid_16 golioth_svc_uuid_16 =
29-
BT_UUID_INIT_16(GOLIOTH_BLE_GATT_UUID_SVC_VAL_16);
27+
BT_UUID_INIT_128(POUCH_GATT_UUID_SVC_VAL_128);
28+
static const struct bt_uuid_16 golioth_svc_uuid_16 = BT_UUID_INIT_16(POUCH_GATT_UUID_SVC_VAL_16);
3029
static const struct bt_uuid_128 char_uuids[POUCH_GATEWAY_GATT_ATTRS] = {
31-
[POUCH_GATEWAY_GATT_ATTR_INFO] = BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_INFO_CHRC_VAL),
32-
[POUCH_GATEWAY_GATT_ATTR_DOWNLINK] = BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_DOWNLINK_CHRC_VAL),
33-
[POUCH_GATEWAY_GATT_ATTR_UPLINK] = BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_UPLINK_CHRC_VAL),
34-
[POUCH_GATEWAY_GATT_ATTR_SERVER_CERT] =
35-
BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_SERVER_CERT_CHRC_VAL),
36-
[POUCH_GATEWAY_GATT_ATTR_DEVICE_CERT] =
37-
BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_DEVICE_CERT_CHRC_VAL),
30+
[POUCH_GATEWAY_GATT_ATTR_INFO] = BT_UUID_INIT_128(POUCH_GATT_UUID_INFO_CHRC_VAL),
31+
[POUCH_GATEWAY_GATT_ATTR_DOWNLINK] = BT_UUID_INIT_128(POUCH_GATT_UUID_DOWNLINK_CHRC_VAL),
32+
[POUCH_GATEWAY_GATT_ATTR_UPLINK] = BT_UUID_INIT_128(POUCH_GATT_UUID_UPLINK_CHRC_VAL),
33+
[POUCH_GATEWAY_GATT_ATTR_SERVER_CERT] = BT_UUID_INIT_128(POUCH_GATT_UUID_SERVER_CERT_CHRC_VAL),
34+
[POUCH_GATEWAY_GATT_ATTR_DEVICE_CERT] = BT_UUID_INIT_128(POUCH_GATT_UUID_DEVICE_CERT_CHRC_VAL),
3835
};
3936
static const struct bt_uuid_16 gatt_ccc_uuid = BT_UUID_INIT_16(BT_UUID_GATT_CCC_VAL);
4037

lib/bt/downlink.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <zephyr/bluetooth/conn.h>
1212
#include <zephyr/bluetooth/gatt.h>
1313

14-
#include <pouch/transport/ble_gatt/common/packetizer.h>
14+
#include <pouch/transport/gatt/common/packetizer.h>
1515

1616
#include <pouch_gateway/bt/connect.h>
1717
#include <pouch_gateway/types.h>
@@ -24,25 +24,25 @@ static void write_response_cb(struct bt_conn *conn,
2424
uint8_t err,
2525
struct bt_gatt_write_params *params);
2626

27-
static enum golioth_ble_gatt_packetizer_result downlink_packet_fill_cb(void *dst,
28-
size_t *dst_len,
29-
void *user_arg)
27+
static enum pouch_gatt_packetizer_result downlink_packet_fill_cb(void *dst,
28+
size_t *dst_len,
29+
void *user_arg)
3030
{
3131
bool last = false;
3232

3333
int ret = pouch_gateway_downlink_get_data(user_arg, dst, dst_len, &last);
3434
if (-EAGAIN == ret)
3535
{
3636
LOG_DBG("Awaiting additional downlink data from cloud");
37-
return GOLIOTH_BLE_GATT_PACKETIZER_MORE_DATA;
37+
return POUCH_GATT_PACKETIZER_MORE_DATA;
3838
}
3939
if (0 > ret)
4040
{
4141
*dst_len = 0;
42-
return GOLIOTH_BLE_GATT_PACKETIZER_ERROR;
42+
return POUCH_GATT_PACKETIZER_ERROR;
4343
}
4444

45-
return last ? GOLIOTH_BLE_GATT_PACKETIZER_NO_MORE_DATA : GOLIOTH_BLE_GATT_PACKETIZER_MORE_DATA;
45+
return last ? POUCH_GATT_PACKETIZER_NO_MORE_DATA : POUCH_GATT_PACKETIZER_MORE_DATA;
4646
}
4747

4848
static int write_downlink_characteristic(struct bt_conn *conn)
@@ -59,17 +59,17 @@ static int write_downlink_characteristic(struct bt_conn *conn)
5959
}
6060

6161
size_t len = mtu - POUCH_GATEWAY_BT_ATT_OVERHEAD;
62-
enum golioth_ble_gatt_packetizer_result ret =
63-
golioth_ble_gatt_packetizer_get(node->packetizer, node->downlink_scratch, &len);
62+
enum pouch_gatt_packetizer_result ret =
63+
pouch_gatt_packetizer_get(node->packetizer, node->downlink_scratch, &len);
6464

65-
if (GOLIOTH_BLE_GATT_PACKETIZER_ERROR == ret)
65+
if (POUCH_GATT_PACKETIZER_ERROR == ret)
6666
{
67-
ret = golioth_ble_gatt_packetizer_error(node->packetizer);
67+
ret = pouch_gatt_packetizer_error(node->packetizer);
6868
LOG_ERR("Error getting downlink data %d", ret);
6969
return ret;
7070
}
7171

72-
if (GOLIOTH_BLE_GATT_PACKETIZER_EMPTY_PAYLOAD == ret)
72+
if (POUCH_GATT_PACKETIZER_EMPTY_PAYLOAD == ret)
7373
{
7474
LOG_DBG("No downlink data available");
7575
return -ENODATA;
@@ -102,7 +102,7 @@ static void write_response_cb(struct bt_conn *conn,
102102
if (err)
103103
{
104104
pouch_gateway_downlink_abort(node->downlink_ctx);
105-
golioth_ble_gatt_packetizer_finish(node->packetizer);
105+
pouch_gatt_packetizer_finish(node->packetizer);
106106

107107
pouch_gateway_bt_finished(conn);
108108
return;
@@ -111,7 +111,7 @@ static void write_response_cb(struct bt_conn *conn,
111111
if (pouch_gateway_downlink_is_complete(node->downlink_ctx))
112112
{
113113
pouch_gateway_downlink_finish(node->downlink_ctx);
114-
golioth_ble_gatt_packetizer_finish(node->packetizer);
114+
pouch_gatt_packetizer_finish(node->packetizer);
115115

116116
pouch_gateway_bt_finished(conn);
117117
}
@@ -121,7 +121,7 @@ static void write_response_cb(struct bt_conn *conn,
121121
if (0 != ret && -ENODATA != ret)
122122
{
123123
pouch_gateway_downlink_abort(node->downlink_ctx);
124-
golioth_ble_gatt_packetizer_finish(node->packetizer);
124+
pouch_gatt_packetizer_finish(node->packetizer);
125125

126126
pouch_gateway_bt_finished(conn);
127127
}
@@ -138,7 +138,7 @@ static void downlink_data_available(void *arg)
138138
if (0 != ret)
139139
{
140140
pouch_gateway_downlink_abort(node->downlink_ctx);
141-
golioth_ble_gatt_packetizer_finish(node->packetizer);
141+
pouch_gatt_packetizer_finish(node->packetizer);
142142

143143
pouch_gateway_bt_finished(conn);
144144
}
@@ -169,7 +169,7 @@ struct pouch_gateway_downlink_context *pouch_gateway_downlink_start(struct bt_co
169169

170170
node->downlink_ctx = pouch_gateway_downlink_init(downlink_data_available, conn);
171171
node->packetizer =
172-
golioth_ble_gatt_packetizer_start_callback(downlink_packet_fill_cb, node->downlink_ctx);
172+
pouch_gatt_packetizer_start_callback(downlink_packet_fill_cb, node->downlink_ctx);
173173

174174
return node->downlink_ctx;
175175
}

lib/bt/scan.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88
#include <zephyr/bluetooth/conn.h>
99
#include <zephyr/bluetooth/uuid.h>
1010

11-
#include <pouch/transport/ble_gatt/common/types.h>
12-
#include <pouch/transport/ble_gatt/common/uuids.h>
11+
#include <pouch/transport/gatt/common/types.h>
12+
#include <pouch/transport/gatt/common/uuids.h>
1313

1414
#include <zephyr/logging/log.h>
1515
LOG_MODULE_REGISTER(scan);
1616

1717
#include <pouch_gateway/bt/scan.h>
1818

19-
static inline bool version_is_compatible(const struct golioth_ble_gatt_adv_data *adv_data)
19+
static inline bool version_is_compatible(const struct pouch_gatt_adv_data *adv_data)
2020
{
21-
uint8_t self_ver = adv_data->version
22-
& GOLIOTH_BLE_GATT_ADV_VERSION_SELF_MASK >> GOLIOTH_BLE_GATT_ADV_VERSION_SELF_SHIFT;
21+
uint8_t self_ver =
22+
adv_data->version & POUCH_GATT_ADV_VERSION_SELF_MASK >> POUCH_GATT_ADV_VERSION_SELF_SHIFT;
2323

24-
return GOLIOTH_BLE_GATT_VERSION == self_ver;
24+
return POUCH_GATT_VERSION == self_ver;
2525
}
2626

27-
static inline bool sync_requested(const struct golioth_ble_gatt_adv_data *adv_data)
27+
static inline bool sync_requested(const struct pouch_gatt_adv_data *adv_data)
2828
{
29-
return (adv_data->flags & GOLIOTH_BLE_GATT_ADV_FLAG_SYNC_REQUEST);
29+
return (adv_data->flags & POUCH_GATT_ADV_FLAG_SYNC_REQUEST);
3030
}
3131

3232
struct tf_data
3333
{
3434
bool is_tf;
35-
struct golioth_ble_gatt_adv_data adv_data;
35+
struct pouch_gatt_adv_data adv_data;
3636
};
3737

3838
static const struct bt_uuid_128 golioth_svc_uuid_128 =
39-
BT_UUID_INIT_128(GOLIOTH_BLE_GATT_UUID_SVC_VAL_128);
40-
static const struct bt_uuid_16 golioth_svc_uuid_16 =
41-
BT_UUID_INIT_16(GOLIOTH_BLE_GATT_UUID_SVC_VAL_16);
39+
BT_UUID_INIT_128(POUCH_GATT_UUID_SVC_VAL_128);
40+
static const struct bt_uuid_16 golioth_svc_uuid_16 = BT_UUID_INIT_16(POUCH_GATT_UUID_SVC_VAL_16);
4241

4342
static bool data_cb(struct bt_data *data, void *user_data)
4443
{
@@ -48,7 +47,7 @@ static bool data_cb(struct bt_data *data, void *user_data)
4847
{
4948
case BT_DATA_SVC_DATA128:
5049
{
51-
const struct golioth_ble_gatt_adv_data *adv_data;
50+
const struct pouch_gatt_adv_data *adv_data;
5251

5352
if (data->data_len >= sizeof(golioth_svc_uuid_128.val) + sizeof(*adv_data)
5453
&& memcmp(golioth_svc_uuid_128.val, data->data, sizeof(golioth_svc_uuid_128.val))
@@ -66,7 +65,7 @@ static bool data_cb(struct bt_data *data, void *user_data)
6665

6766
case BT_DATA_SVC_DATA16:
6867
{
69-
const struct golioth_ble_gatt_adv_data *adv_data;
68+
const struct pouch_gatt_adv_data *adv_data;
7069

7170
if (data->data_len >= sizeof(golioth_svc_uuid_16.val) + sizeof(*adv_data)
7271
&& memcmp(&golioth_svc_uuid_16.val, data->data, sizeof(golioth_svc_uuid_16.val))

lib/bt/uplink.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <zephyr/bluetooth/conn.h>
1111
#include <zephyr/bluetooth/gatt.h>
1212

13-
#include <pouch/transport/ble_gatt/common/packetizer.h>
13+
#include <pouch/transport/gatt/common/packetizer.h>
1414

1515
#include <pouch_gateway/types.h>
1616
#include <pouch_gateway/uplink.h>
@@ -26,8 +26,7 @@ static uint8_t handle_uplink_payload(struct bt_conn *conn, const void *data, uin
2626
bool is_first = false;
2727
bool is_last = false;
2828
const void *payload = NULL;
29-
ssize_t payload_len =
30-
golioth_ble_gatt_packetizer_decode(data, length, &payload, &is_first, &is_last);
29+
ssize_t payload_len = pouch_gatt_packetizer_decode(data, length, &payload, &is_first, &is_last);
3130
if (payload_len < 0)
3231
{
3332
LOG_ERR("Failed to decode BLE GATT %s (err %d)", "Uplink", (int) payload_len);

samples/custom_connect/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ CONFIG_MAIN_STACK_SIZE=2048
3939
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
4040

4141
# Pouch BLE GATT Transport
42-
CONFIG_POUCH_TRANSPORT_BLE_GATT_COMMON=y
42+
CONFIG_POUCH_TRANSPORT_GATT_COMMON=y
4343

4444
CONFIG_ZVFS_EVENTFD_MAX=11

samples/custom_connect/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <golioth/gateway.h>
1515
#include <samples/common/sample_credentials.h>
1616

17-
#include <pouch/transport/ble_gatt/common/types.h>
17+
#include <pouch/transport/gatt/common/types.h>
1818

1919
#include <pouch_gateway/bt/connect.h>
2020
#include <pouch_gateway/cert.h>
@@ -181,7 +181,7 @@ void pouch_gateway_bt_finished(struct bt_conn *conn)
181181
int main(void)
182182
{
183183
LOG_INF("Gateway Version: " STRINGIFY(GIT_DESCRIBE));
184-
LOG_INF("Pouch BLE Transport Protocol Version: %d", GOLIOTH_BLE_GATT_VERSION);
184+
LOG_INF("Pouch BLE Transport Protocol Version: %d", POUCH_GATT_VERSION);
185185

186186
k_work_init_delayable(&sync_data.work, sync_start_handler);
187187

0 commit comments

Comments
 (0)