Skip to content

Commit 8af2178

Browse files
committed
Pull in SDK renaming change
1 parent f5af41a commit 8af2178

File tree

257 files changed

+10699
-10991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+10699
-10991
lines changed

.clang-format

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ PenaltyReturnTypeOnItsOwnLine: 240
2929
WhitespaceSensitiveMacros:
3030
- EMBED_FILE
3131
ForEachMacros:
32-
- GGL_LIST_FOREACH
33-
- GGL_MAP_FOREACH
34-
- GGL_BUF_LIST_FOREACH
32+
- GG_LIST_FOREACH
33+
- GG_MAP_FOREACH
34+
- GG_BUF_LIST_FOREACH
3535
Macros:
3636
- NODISCARD=[[nodiscard]]
3737
- GGL_EXPORT=[[gnu::visibility(protected)]]

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ check_c_source_compiles(
268268
# Add components
269269
#
270270

271-
add_subdirectory(${ggl_sdk_SOURCE_DIR} ggl-sdk)
272-
target_include_directories(ggl-sdk INTERFACE ${ggl_sdk_SOURCE_DIR}/priv_include)
271+
add_subdirectory(${gg_sdk_SOURCE_DIR} gg-sdk)
272+
target_include_directories(gg-sdk INTERFACE ${gg_sdk_SOURCE_DIR}/priv_include)
273273

274274
# Common setup for a GGL module
275275
function(ggl_init_module name)
@@ -296,7 +296,7 @@ function(ggl_init_module name)
296296
# src/dummy.c
297297
if(NOT SRCS_LEN EQUAL 0)
298298
add_library(${name} STATIC ${SRCS})
299-
target_compile_definitions(${name} PRIVATE "GGL_MODULE=(\"${name}\")")
299+
target_compile_definitions(${name} PRIVATE "GG_MODULE=(\"${name}\")")
300300
target_include_directories(${name} PUBLIC ${COMP_ARG_INCDIRS})
301301
target_link_libraries(${name} PRIVATE ${COMP_ARG_LIBS})
302302
endif()
@@ -325,7 +325,7 @@ function(ggl_init_module name)
325325
get_filename_component(bin_name ${bin} NAME_WLE)
326326
add_executable(${bin_name}-bin ${bin})
327327
target_compile_definitions(${bin_name}-bin
328-
PRIVATE "GGL_MODULE=(\"${name}\")")
328+
PRIVATE "GG_MODULE=(\"${name}\")")
329329
if(NOT SRCS_LEN EQUAL 0)
330330
target_link_libraries(${bin_name}-bin PRIVATE ${name})
331331
endif()

fc_deps.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"rev": "f0409ced6c2c9430f0e972019b7e8f20bbf58f4e",
1010
"hash": "sha256-6is4ymM/Ct9JntgpFHF4Vlv5+GUwy0HZvEiEV+ALJkw="
1111
},
12-
"ggl_sdk": {
12+
"gg_sdk": {
1313
"url": "https://github.com/aws-greengrass/aws-greengrass-sdk-lite.git",
14-
"rev": "febee8463690b30580a8fdfddcceebb66596195d",
15-
"hash": "sha256-yObuWnBN+VTcIpyo9ihVf2/7uXb/cA/QilC8TrwSFVo="
14+
"rev": "08be374523066becf92dce52c84d3cb9bf3825a5",
15+
"hash": "sha256-mpbcK18nRJYLo/tRgecQUT0bnEL+KCtKCQgKOYAaojY="
1616
}
1717
}

modules/aws-iot-call/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
ggl_init_module(aws-iot-call LIBS ggl-sdk core-bus core-bus-aws-iot-mqtt)
5+
ggl_init_module(aws-iot-call LIBS gg-sdk core-bus core-bus-aws-iot-mqtt)

modules/aws-iot-call/include/ggl/aws_iot_call.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77

88
//! Helper for calling AWS IoT Core APIs
99

10-
#include <ggl/arena.h>
11-
#include <ggl/buffer.h>
12-
#include <ggl/error.h>
13-
#include <ggl/object.h>
10+
#include <gg/arena.h>
11+
#include <gg/buffer.h>
12+
#include <gg/error.h>
13+
#include <gg/object.h>
1414
#include <stdbool.h>
1515

1616
/// Make a call to an AWS IoT MQTT API.
1717
/// Sends request on topic and waits for response on topic/(accepted|rejected).
1818
/// Responses will be filtered according to clientToken.
19-
GglError ggl_aws_iot_call(
20-
GglBuffer socket_name,
21-
GglBuffer topic,
22-
GglObject payload,
19+
GgError ggl_aws_iot_call(
20+
GgBuffer socket_name,
21+
GgBuffer topic,
22+
GgObject payload,
2323
bool virtual,
24-
GglArena *alloc,
25-
GglObject *result
24+
GgArena *alloc,
25+
GgObject *result
2626
);
2727

2828
#endif

modules/aws-iot-call/src/aws_iot_call.c

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
#include "ggl/aws_iot_call.h"
66
#include <assert.h>
77
#include <errno.h>
8-
#include <ggl/arena.h>
9-
#include <ggl/buffer.h>
10-
#include <ggl/cleanup.h>
8+
#include <gg/arena.h>
9+
#include <gg/buffer.h>
10+
#include <gg/cleanup.h>
11+
#include <gg/error.h>
12+
#include <gg/json_decode.h>
13+
#include <gg/json_encode.h>
14+
#include <gg/log.h>
15+
#include <gg/map.h>
16+
#include <gg/object.h>
17+
#include <gg/vector.h>
1118
#include <ggl/core_bus/aws_iot_mqtt.h>
1219
#include <ggl/core_bus/client.h> // IWYU pragma: keep (cleanup)
13-
#include <ggl/error.h>
14-
#include <ggl/json_decode.h>
15-
#include <ggl/json_encode.h>
16-
#include <ggl/log.h>
17-
#include <ggl/map.h>
18-
#include <ggl/object.h>
19-
#include <ggl/vector.h>
2020
#include <pthread.h>
2121
#include <sys/types.h>
2222
#include <time.h>
@@ -35,44 +35,44 @@ typedef struct {
3535
pthread_mutex_t *mtx;
3636
pthread_cond_t *cond;
3737
bool ready;
38-
GglBuffer *client_token;
39-
GglArena *alloc;
40-
GglObject *result;
41-
GglError ret;
38+
GgBuffer *client_token;
39+
GgArena *alloc;
40+
GgObject *result;
41+
GgError ret;
4242
} CallbackCtx;
4343

4444
static void cleanup_pthread_cond(pthread_cond_t **cond) {
4545
pthread_cond_destroy(*cond);
4646
}
4747

48-
static GglError get_client_token(GglObject payload, GglBuffer **client_token) {
48+
static GgError get_client_token(GgObject payload, GgBuffer **client_token) {
4949
assert(client_token != NULL);
5050
assert(*client_token != NULL);
5151

52-
if (ggl_obj_type(payload) != GGL_TYPE_MAP) {
52+
if (gg_obj_type(payload) != GG_TYPE_MAP) {
5353
*client_token = NULL;
54-
return GGL_ERR_OK;
54+
return GG_ERR_OK;
5555
}
56-
GglMap payload_map = ggl_obj_into_map(payload);
56+
GgMap payload_map = gg_obj_into_map(payload);
5757

58-
GglObject *found;
59-
if (!ggl_map_get(payload_map, GGL_STR("clientToken"), &found)) {
58+
GgObject *found;
59+
if (!gg_map_get(payload_map, GG_STR("clientToken"), &found)) {
6060
*client_token = NULL;
61-
return GGL_ERR_OK;
61+
return GG_ERR_OK;
6262
}
63-
if (ggl_obj_type(*found) != GGL_TYPE_BUF) {
64-
GGL_LOGE("Invalid clientToken type.");
65-
return GGL_ERR_INVALID;
63+
if (gg_obj_type(*found) != GG_TYPE_BUF) {
64+
GG_LOGE("Invalid clientToken type.");
65+
return GG_ERR_INVALID;
6666
}
67-
**client_token = ggl_obj_into_buf(*found);
68-
return GGL_ERR_OK;
67+
**client_token = gg_obj_into_buf(*found);
68+
return GG_ERR_OK;
6969
}
7070

71-
static bool match_client_token(GglObject payload, GglBuffer *client_token) {
72-
GglBuffer *payload_client_token = &(GglBuffer) { 0 };
71+
static bool match_client_token(GgObject payload, GgBuffer *client_token) {
72+
GgBuffer *payload_client_token = &(GgBuffer) { 0 };
7373

74-
GglError ret = get_client_token(payload, &payload_client_token);
75-
if (ret != GGL_ERR_OK) {
74+
GgError ret = get_client_token(payload, &payload_client_token);
75+
if (ret != GG_ERR_OK) {
7676
return false;
7777
}
7878

@@ -84,93 +84,92 @@ static bool match_client_token(GglObject payload, GglBuffer *client_token) {
8484
return false;
8585
}
8686

87-
return ggl_buffer_eq(*client_token, *payload_client_token);
87+
return gg_buffer_eq(*client_token, *payload_client_token);
8888
}
8989

90-
static GglError subscription_callback(
91-
void *ctx, uint32_t handle, GglObject data
90+
static GgError subscription_callback(
91+
void *ctx, uint32_t handle, GgObject data
9292
) {
9393
(void) handle;
9494
CallbackCtx *call_ctx = ctx;
9595

96-
GglBuffer topic;
97-
GglBuffer payload = { 0 };
98-
GglError ret
99-
= ggl_aws_iot_mqtt_subscribe_parse_resp(data, &topic, &payload);
100-
if (ret != GGL_ERR_OK) {
96+
GgBuffer topic;
97+
GgBuffer payload = { 0 };
98+
GgError ret = ggl_aws_iot_mqtt_subscribe_parse_resp(data, &topic, &payload);
99+
if (ret != GG_ERR_OK) {
101100
return ret;
102101
}
103102

104103
bool decoded = true;
105-
ret = ggl_json_decode_destructive(
104+
ret = gg_json_decode_destructive(
106105
payload, call_ctx->alloc, call_ctx->result
107106
);
108-
if (ret != GGL_ERR_OK) {
109-
GGL_LOGE("Failed to decode response payload.");
110-
*(call_ctx->result) = GGL_OBJ_NULL;
107+
if (ret != GG_ERR_OK) {
108+
GG_LOGE("Failed to decode response payload.");
109+
*(call_ctx->result) = GG_OBJ_NULL;
111110
decoded = false;
112111
}
113112

114113
if (!match_client_token(*call_ctx->result, call_ctx->client_token)) {
115114
// Skip this message
116-
return GGL_ERR_OK;
115+
return GG_ERR_OK;
117116
}
118117

119-
if (ggl_buffer_has_suffix(topic, GGL_STR("/accepted"))) {
118+
if (gg_buffer_has_suffix(topic, GG_STR("/accepted"))) {
120119
if (!decoded) {
121-
return GGL_ERR_INVALID;
120+
return GG_ERR_INVALID;
122121
}
123-
call_ctx->ret = GGL_ERR_OK;
124-
} else if (ggl_buffer_has_suffix(topic, GGL_STR("/rejected"))) {
125-
GGL_LOGE(
122+
call_ctx->ret = GG_ERR_OK;
123+
} else if (gg_buffer_has_suffix(topic, GG_STR("/rejected"))) {
124+
GG_LOGE(
126125
"Received rejected response: %.*s", (int) payload.len, payload.data
127126
);
128-
call_ctx->ret = GGL_ERR_REMOTE;
127+
call_ctx->ret = GG_ERR_REMOTE;
129128
} else {
130-
return GGL_ERR_INVALID;
129+
return GG_ERR_INVALID;
131130
}
132131

133132
// Err to close subscription
134-
return GGL_ERR_EXPECTED;
133+
return GG_ERR_EXPECTED;
135134
}
136135

137136
static void subscription_close_callback(void *ctx, uint32_t handle) {
138137
(void) handle;
139138
CallbackCtx *call_ctx = ctx;
140139

141-
GGL_MTX_SCOPE_GUARD(call_ctx->mtx);
140+
GG_MTX_SCOPE_GUARD(call_ctx->mtx);
142141
call_ctx->ready = true;
143142
pthread_cond_signal(call_ctx->cond);
144143
}
145144

146-
GglError ggl_aws_iot_call(
147-
GglBuffer socket_name,
148-
GglBuffer topic,
149-
GglObject payload,
145+
GgError ggl_aws_iot_call(
146+
GgBuffer socket_name,
147+
GgBuffer topic,
148+
GgObject payload,
150149
bool virtual,
151-
GglArena *alloc,
152-
GglObject *result
150+
GgArena *alloc,
151+
GgObject *result
153152
) {
154153
static pthread_mutex_t mem_mtx = PTHREAD_MUTEX_INITIALIZER;
155-
GGL_MTX_SCOPE_GUARD(&mem_mtx);
154+
GG_MTX_SCOPE_GUARD(&mem_mtx);
156155

157156
// TODO: Share memory for topic filter and encode
158157
static uint8_t topic_filter_mem[AWS_IOT_MAX_TOPIC_SIZE];
159158
static uint8_t json_encode_mem[GGL_MAX_IOT_CORE_API_PAYLOAD_LEN];
160159

161-
GglByteVec topic_filter = GGL_BYTE_VEC(topic_filter_mem);
160+
GgByteVec topic_filter = GG_BYTE_VEC(topic_filter_mem);
162161

163-
GglError ret = ggl_byte_vec_append(&topic_filter, topic);
164-
ggl_byte_vec_chain_append(&ret, &topic_filter, GGL_STR("/+"));
165-
if (ret != GGL_ERR_OK) {
166-
GGL_LOGE("Failed to construct response topic filter.");
162+
GgError ret = gg_byte_vec_append(&topic_filter, topic);
163+
gg_byte_vec_chain_append(&ret, &topic_filter, GG_STR("/+"));
164+
if (ret != GG_ERR_OK) {
165+
GG_LOGE("Failed to construct response topic filter.");
167166
return ret;
168167
}
169168

170-
GglByteVec payload_vec = GGL_BYTE_VEC(json_encode_mem);
171-
ret = ggl_json_encode(payload, ggl_byte_vec_writer(&payload_vec));
172-
if (ret != GGL_ERR_OK) {
173-
GGL_LOGE("Failed to encode JSON payload.");
169+
GgByteVec payload_vec = GG_BYTE_VEC(json_encode_mem);
170+
ret = gg_json_encode(payload, gg_byte_vec_writer(&payload_vec));
171+
if (ret != GG_ERR_OK) {
172+
GG_LOGE("Failed to encode JSON payload.");
174173
return ret;
175174
}
176175

@@ -180,45 +179,45 @@ GglError ggl_aws_iot_call(
180179
pthread_cond_t notify_cond;
181180
pthread_cond_init(&notify_cond, &notify_condattr);
182181
pthread_condattr_destroy(&notify_condattr);
183-
GGL_CLEANUP(cleanup_pthread_cond, &notify_cond);
182+
GG_CLEANUP(cleanup_pthread_cond, &notify_cond);
184183
pthread_mutex_t notify_mtx = PTHREAD_MUTEX_INITIALIZER;
185184

186185
CallbackCtx ctx = {
187186
.mtx = &notify_mtx,
188187
.cond = &notify_cond,
189188
.ready = false,
190-
.client_token = &(GglBuffer) { 0 },
189+
.client_token = &(GgBuffer) { 0 },
191190
.alloc = alloc,
192191
.result = result,
193-
.ret = GGL_ERR_FAILURE,
192+
.ret = GG_ERR_FAILURE,
194193
};
195194

196195
ret = get_client_token(payload, &ctx.client_token);
197-
if (ret != GGL_ERR_OK) {
196+
if (ret != GG_ERR_OK) {
198197
return ret;
199198
}
200199

201200
uint32_t sub_handle = 0;
202201
ret = ggl_aws_iot_mqtt_subscribe(
203202
socket_name,
204-
GGL_BUF_LIST(topic_filter.buf),
203+
GG_BUF_LIST(topic_filter.buf),
205204
1,
206205
virtual,
207206
subscription_callback,
208207
subscription_close_callback,
209208
&ctx,
210209
&sub_handle
211210
);
212-
if (ret != GGL_ERR_OK) {
213-
GGL_LOGE("Response topic subscription failed.");
211+
if (ret != GG_ERR_OK) {
212+
GG_LOGE("Response topic subscription failed.");
214213
return ret;
215214
}
216215

217216
ret = ggl_aws_iot_mqtt_publish(
218217
socket_name, topic, payload_vec.buf, 1, true
219218
);
220-
if (ret != GGL_ERR_OK) {
221-
GGL_LOGE("Response topic subscription failed.");
219+
if (ret != GG_ERR_OK) {
220+
GG_LOGE("Response topic subscription failed.");
222221
ggl_client_sub_close(sub_handle);
223222
return ret;
224223
}
@@ -232,14 +231,14 @@ GglError ggl_aws_iot_call(
232231
{
233232
// Must be unlocked before closing subscription
234233
// (else subscription response may be blocked, and close would deadlock)
235-
GGL_MTX_SCOPE_GUARD(&notify_mtx);
234+
GG_MTX_SCOPE_GUARD(&notify_mtx);
236235

237236
while (!ctx.ready) {
238237
int cond_ret
239238
= pthread_cond_timedwait(&notify_cond, &notify_mtx, &timeout);
240239
if ((cond_ret != 0) && (cond_ret != EINTR)) {
241240
assert(cond_ret == ETIMEDOUT);
242-
GGL_LOGW("Timed out waiting for a response.");
241+
GG_LOGW("Timed out waiting for a response.");
243242
timed_out = true;
244243
break;
245244
}

modules/core-bus-aws-iot-mqtt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
ggl_init_module(core-bus-aws-iot-mqtt LIBS ggl-sdk core-bus)
5+
ggl_init_module(core-bus-aws-iot-mqtt LIBS gg-sdk core-bus)

0 commit comments

Comments
 (0)