Skip to content
This repository was archived by the owner on Sep 13, 2020. It is now read-only.

Commit d18d78c

Browse files
committed
Merge pull request #69 from mtl2034/master
adding support for custom server
2 parents 8c2b9a7 + 83c51e3 commit d18d78c

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT(parse-embedded, 1.0.3, [email protected])
1+
AC_INIT(parse-embedded, 1.0.4, [email protected])
22
AC_CONFIG_AUX_DIR(config)
33
AC_CONFIG_SRCDIR(common/simplejson.c)
44
AC_CONFIG_SRCDIR(unix/src/parse.c)

openwrt/parse-embedded/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
include $(TOPDIR)/rules.mk
1111

1212
PKG_NAME:=parse-embedded
13-
PKG_VERSION:=1.0.3
13+
PKG_VERSION:=1.0.4
1414
PKG_RELEASE:=1
1515

1616
PKG_SOURCE:=$(PKG_NAME)-sdks-$(PKG_VERSION).tar.gz

unix/yun/parse_request.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ int main(int argc , char **argv) {
169169
exit(0);
170170
}
171171

172-
ParseClient client = parseInitialize(g_cAppID,g_cClientKey);
172+
ParseClient client;
173+
if (g_cServerURL[0] == '\0') {
174+
client = parseInitialize(g_cAppID, g_cClientKey);
175+
} else {
176+
client = parseInitializeWithServerURL(g_cAppID, g_cClientKey, g_cServerURL);
177+
}
173178

174179
if(g_cInstallationID[0] != '\0') {
175180
parseSetInstallationId(client, g_cInstallationID);

unix/yun/yun.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ char g_cAppID[APPLICATION_ID_MAX_LEN + 1] = {0};
3333
char g_cClientKey[CLIENT_KEY_MAX_LEN + 1] = {0};
3434
char g_cInstallationID[INSTALLATION_ID_MAX_LEN + 1] ={0};
3535
char g_cSessionToken[SESSION_TOKEN_MAX_LEN + 1] = {0};
36+
char g_cServerURL[SERVER_URL_MAX_LEN + 1] = {0};
3637

3738
int yunReadProvisioningInfo() {
3839
int socketHandle = -1;
@@ -82,6 +83,17 @@ int yunReadProvisioningInfo() {
8283
strncpy(g_cSessionToken, value, sizeof(g_cSessionToken));
8384
}
8485
}
86+
87+
// read serverURL
88+
memset(buf, 0, sizeof(buf));
89+
memset(value, 0, sizeof(value));
90+
tcp_write(socketHandle, "{\"command\": \"get\", \"key\": \"serverURL\"}\n");
91+
if (tcp_read(socketHandle, buf, sizeof(buf) - 1, 2)) {
92+
getValueFromJSON(buf, "value", value, sizeof(value));
93+
if(strcmp("null", value) != 0) {
94+
strncpy(g_cServerURL, value, sizeof(g_cServerURL));
95+
}
96+
}
8597
tcp_close(socketHandle);
8698
return 1;
8799
} else {

unix/yun/yun.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern char g_cAppID[APPLICATION_ID_MAX_LEN + 1];
2828
extern char g_cClientKey[CLIENT_KEY_MAX_LEN + 1];
2929
extern char g_cInstallationID[INSTALLATION_ID_MAX_LEN + 1];
3030
extern char g_cSessionToken[SESSION_TOKEN_MAX_LEN + 1];
31+
extern char g_cServerURL[SERVER_URL_MAX_LEN + 1];
3132

3233
int yunReadProvisioningInfo();
3334

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)