1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #ifndef _LINKKIT_GATEWAY_LEGACY_H_
6 #define _LINKKIT_GATEWAY_LEGACY_H_
7 
8 #include "linkkit/infra/infra_list.h"
9 #include "linkkit_gateway_export.h"
10 
11 #define LINKKIT_GATEWAY_LEGACY_KEY_ID                  "id"
12 #define LINKKIT_GATEWAY_LEGACY_KEY_CODE                "code"
13 #define LINKKIT_GATEWAY_LEGACY_KEY_DEVID               "devid"
14 #define LINKKIT_GATEWAY_LEGACY_KEY_SERVICEID           "serviceid"
15 #define LINKKIT_GATEWAY_LEGACY_KEY_PROPERTYID          "propertyid"
16 #define LINKKIT_GATEWAY_LEGACY_KEY_EVENTID             "eventid"
17 #define LINKKIT_GATEWAY_LEGACY_KEY_PAYLOAD             "payload"
18 #define LINKKIT_GATEWAY_LEGACY_KEY_PRODUCT_KEY         "productKey"
19 #define LINKKIT_GATEWAY_LEGACY_KEY_TIME                "time"
20 #define LINKKIT_GATEWAY_LEGACY_KEY_VERSION             "version"
21 
22 #define LINKKIT_GATEWAY_LEGACY_SYNC_DEFAULT_TIMEOUT_MS (10000)
23 
24 typedef struct {
25     int devid;
26     linkkit_cbs_t *callback;
27     void *callback_ctx;
28     struct list_head linked_list;
29 } linkkit_gateway_dev_callback_node_t;
30 
31 typedef void (*linkkit_gateway_upstream_async_callback)(int retval, void *ctx);
32 typedef struct {
33     int msgid;
34     void *semaphore;
35     int code;
36     struct list_head linked_list;
37 } linkkit_gateway_upstream_sync_callback_node_t;
38 
39 typedef struct {
40     int msgid;
41     int timeout_ms;
42     uint64_t timestamp_ms;
43     linkkit_gateway_upstream_async_callback callback;
44     void *callback_ctx;
45     struct list_head linked_list;
46 } linkkit_gateway_upstream_async_callback_node_t;
47 
48 typedef struct {
49     void *mutex;
50     void *upstream_mutex;
51     int is_inited;
52     int is_started;
53     linkkit_params_t init_params;
54     void *dispatch_thread;
55     handle_service_fota_callback_fp_t fota_callback;
56     struct list_head dev_callback_list;
57     struct list_head upstream_sync_callback_list;
58     struct list_head upstream_async_callback_list;
59 } linkkit_gateway_legacy_ctx_t;
60 
61 #endif
62