29#if (MODULE_MEGAWIFI != 0)
40 GJ_ERR_RECEPTION = -3,
46enum gj_trophy_difficulty {
47 GJ_TROPHY_TYPE_BRONZE = 0,
48 GJ_TROPHY_TYPE_SILVER,
50 GJ_TROPHY_TYPE_PLATINUM,
51 GJ_TROPHY_TYPE_UNKNOWN
55enum gj_data_store_update_operation {
66#define GJ_TROPHY_RESPONSE_TABLE(X_MACRO) \
67 X_MACRO(id, string, char*) \
68 X_MACRO(title, string, char*) \
69 X_MACRO(difficulty, trophy_difficulty, enum gj_trophy_difficulty) \
70 X_MACRO(description, string, char*) \
71 X_MACRO(image_url, string, char*) \
72 X_MACRO(achieved, string, char*)
75#define GJ_TIME_RESPONSE_TABLE(X_MACRO) \
76 X_MACRO(timestamp, string, char*) \
77 X_MACRO(timezone, string, char*) \
78 X_MACRO(day, string, char*) \
79 X_MACRO(hour, string, char*) \
80 X_MACRO(minute, string, char*) \
81 X_MACRO(second, string, char*)
84#define GJ_SCORE_RESPONSE_TABLE(X_MACRO) \
85 X_MACRO(score, string, char*) \
86 X_MACRO(sort, string, char*) \
87 X_MACRO(extra_data, string, char*) \
88 X_MACRO(user, string, char*) \
89 X_MACRO(user_id, string, char*) \
90 X_MACRO(guest, string, char*) \
91 X_MACRO(stored, string, char*) \
92 X_MACRO(stored_timestamp, string, char*)
95#define GJ_SCORE_TABLE_RESPONSE_TABLE(X_MACRO) \
96 X_MACRO(id, string, char*) \
97 X_MACRO(name, string, char*) \
98 X_MACRO(description, string, char*) \
99 X_MACRO(primary, bool_num, bool)
102#define GJ_SCORE_GETRANK_RESPONSE_TABLE(X_MACRO) \
103 X_MACRO(message, string, char*) \
104 X_MACRO(rank, string, char*)
107#define GJ_USER_RESPONSE_TABLE(X_MACRO) \
108 X_MACRO(id, string, char*) \
109 X_MACRO(type, string, char*) \
110 X_MACRO(username, string, char*) \
111 X_MACRO(avatar_url, string, char*) \
112 X_MACRO(signed_up, string, char*) \
113 X_MACRO(signed_up_timestamp, string, char*) \
114 X_MACRO(last_logged_in, string, char*) \
115 X_MACRO(last_logged_in_timestamp, string, char*) \
116 X_MACRO(status, string, char*) \
117 X_MACRO(developer_name, string, char*) \
118 X_MACRO(developer_website, string, char*) \
119 X_MACRO(developer_description, string, char*)
122#define X_AS_STRUCT(field, decoder, type) \
127 GJ_TROPHY_RESPONSE_TABLE(X_AS_STRUCT);
133 GJ_TIME_RESPONSE_TABLE(X_AS_STRUCT);
138 GJ_SCORE_RESPONSE_TABLE(X_AS_STRUCT);
142struct gj_score_table {
143 GJ_SCORE_TABLE_RESPONSE_TABLE(X_AS_STRUCT);
148 GJ_USER_RESPONSE_TABLE(X_AS_STRUCT);
174bool gj_init(
const char *endpoint,
const char *game_id,
const char *private_key,
175 const char *username,
const char *user_token,
char *reply_buf,
176 uint16_t buf_len, uint16_t tout_frames);
186enum gj_error gj_get_error(
void);
198char *gj_trophies_fetch(
bool achieved,
const char *trophy_id);
214char *gj_trophy_get_next(
char *pos,
struct gj_trophy *trophy);
223bool gj_trophy_add_achieved(
const char *trophy_id);
232bool gj_trophy_remove_achieved(
const char *trophy_id);
242const char *gj_trophy_difficulty_str(
enum gj_trophy_difficulty difficulty);
251bool gj_time(
struct gj_time *time);
268char *gj_scores_fetch(
const char *limit,
const char *table_id,
269 const char *guest,
const char *better_than,
270 const char *worse_than,
bool only_user);
286char *gj_score_get_next(
char *pos,
struct gj_score *score);
294char *gj_scores_tables_fetch(
void);
310char *gj_score_table_get_next(
char *pos,
struct gj_score_table *score_table);
320char *gj_scores_get_rank(
const char *sort,
const char *table_id);
333bool gj_scores_add(
const char *score,
const char *sort,
const char *table_id,
334 const char *guest,
const char *extra_data);
346bool gj_data_store_set(
const char *key,
const char *data,
bool user_store);
359char *gj_data_store_keys_fetch(
const char *pattern,
bool user_store);
375char *gj_data_store_key_next(
char *pos,
char **key);
387char *data_store_fetch(
const char *key,
bool user_store);
400char *gj_data_store_update(
const char *key,
401 enum gj_data_store_update_operation operation,
402 const char *value,
bool user_store);
413bool gj_data_store_remove(
const char *key,
bool user_store);
420bool gj_sessions_open(
void);
430bool gj_sessions_ping(
bool active);
446bool gj_sessions_check(
const char *username,
const char *user_token);
453bool gj_sessions_close(
void);
468char *gj_users_fetch(
const char *username,
const char *user_id);
484char *gj_user_get_next(
char *pos,
struct gj_user *user);
495bool gj_users_auth(
void);
503char *gj_friends_fetch(
void);
519char *gj_friend_get_next(
char *pos,
char **user_id);
537char *gj_request(
const char **path, uint8_t num_paths,
const char **key,
538 const char **value, uint8_t num_kv_pairs, uint32_t *out_len);