REST processing fixed in server. Major packet handling bug found.
This commit is contained in:
parent
41a45260c4
commit
d7dcd43c5f
7 changed files with 22 additions and 13 deletions
|
@ -257,6 +257,9 @@ int main(int argc, char *argv[]) {
|
||||||
__runtimeData.strings = NULL;
|
__runtimeData.strings = NULL;
|
||||||
__runtimeData.protocolVersion = 0;
|
__runtimeData.protocolVersion = 0;
|
||||||
|
|
||||||
|
sh_new_strdup(__runtimeData.integers);
|
||||||
|
sh_new_strdup(__runtimeData.strings);
|
||||||
|
|
||||||
//taskCreate(taskComDebugLoop, NULL);
|
//taskCreate(taskComDebugLoop, NULL);
|
||||||
taskCreate(taskWelcome, NULL);
|
taskCreate(taskWelcome, NULL);
|
||||||
taskCreate(taskGuiEventLoop, NULL);
|
taskCreate(taskGuiEventLoop, NULL);
|
||||||
|
|
|
@ -183,7 +183,6 @@ static void taskConnectClick(void *data) {
|
||||||
|
|
||||||
case PACKET_TYPE_VERSION:
|
case PACKET_TYPE_VERSION:
|
||||||
__runtimeData.protocolVersion = *(uint32_t *)decoded->data;
|
__runtimeData.protocolVersion = *(uint32_t *)decoded->data;
|
||||||
packetDecodeDataDestroy(&decoded);
|
|
||||||
// Do we need to update?
|
// Do we need to update?
|
||||||
if (PACKET_PROTOCOL_VERSION == __runtimeData.protocolVersion) {
|
if (PACKET_PROTOCOL_VERSION == __runtimeData.protocolVersion) {
|
||||||
// Nope, we're good.
|
// Nope, we're good.
|
||||||
|
@ -207,6 +206,7 @@ static void taskConnectClick(void *data) {
|
||||||
logWrite("Unexpected packet received: %d\n", decoded->packetType);
|
logWrite("Unexpected packet received: %d\n", decoded->packetType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
packetDecodeDataDestroy(&decoded);
|
||||||
}
|
}
|
||||||
taskYield();
|
taskYield();
|
||||||
if (__timerSecondTick) timeout--;
|
if (__timerSecondTick) timeout--;
|
||||||
|
|
|
@ -76,8 +76,8 @@ class KwConfig {
|
||||||
if (V::minlength($input['data'], 1) === false) {
|
if (V::minlength($input['data'], 1) === false) {
|
||||||
throw new InvalidArgumentException('The data must not be empty');
|
throw new InvalidArgumentException('The data must not be empty');
|
||||||
}
|
}
|
||||||
if (V::maxlength($input['data'], 4096) === false) {
|
if (V::maxlength($input['data'], 1024) === false) {
|
||||||
throw new InvalidArgumentException('The data must not be longer than 4096 characters');
|
throw new InvalidArgumentException('The data must not be longer than 1024 characters');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (V::maxlength($input['description'], 255) === false) {
|
if (V::maxlength($input['description'], 255) === false) {
|
||||||
|
|
|
@ -76,8 +76,8 @@ class KwStrings {
|
||||||
if (V::minlength($input['data'], 1) === false) {
|
if (V::minlength($input['data'], 1) === false) {
|
||||||
throw new InvalidArgumentException('The data must not be empty');
|
throw new InvalidArgumentException('The data must not be empty');
|
||||||
}
|
}
|
||||||
if (V::maxlength($input['data'], 4096) === false) {
|
if (V::maxlength($input['data'], 1024) === false) {
|
||||||
throw new InvalidArgumentException('The data must not be longer than 4096 characters');
|
throw new InvalidArgumentException('The data must not be longer than 1024 characters');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (V::maxlength($input['description'], 255) === false) {
|
if (V::maxlength($input['description'], 255) === false) {
|
||||||
|
|
|
@ -136,6 +136,7 @@ static void clientProcessPacket(ClientThreadT *client, PacketDecodeDataT *data)
|
||||||
// Send it.
|
// Send it.
|
||||||
packetSend(client->packetThreadData, &encoded);
|
packetSend(client->packetThreadData, &encoded);
|
||||||
DEL(buffer);
|
DEL(buffer);
|
||||||
|
//logWrite("[%s] = [%s]\r\n", strings[i].key, strings[i].value);
|
||||||
}
|
}
|
||||||
restHelperConfigStringMapRelease(strings);
|
restHelperConfigStringMapRelease(strings);
|
||||||
// Fetch number table from REST.
|
// Fetch number table from REST.
|
||||||
|
@ -174,6 +175,7 @@ static void clientProcessPacket(ClientThreadT *client, PacketDecodeDataT *data)
|
||||||
// Send it.
|
// Send it.
|
||||||
packetSend(client->packetThreadData, &encoded);
|
packetSend(client->packetThreadData, &encoded);
|
||||||
DEL(buffer);
|
DEL(buffer);
|
||||||
|
//logWrite("[%s] = [%d]\r\n", integers[i].key, integers[i].value);
|
||||||
}
|
}
|
||||||
restHelperConfigIntegerMapRelease(integers);
|
restHelperConfigIntegerMapRelease(integers);
|
||||||
// Build PROCEED packet.
|
// Build PROCEED packet.
|
||||||
|
|
|
@ -52,7 +52,7 @@ int64_t restHelperConfigIntegerGet(json_object *object, char *name, int64_t defa
|
||||||
json_object *item = NULL;
|
json_object *item = NULL;
|
||||||
int64_t result = defaultValue;
|
int64_t result = defaultValue;
|
||||||
|
|
||||||
config = json_object_object_get(object, "config");
|
config = json_object_object_get(object, "payload");
|
||||||
if (config) {
|
if (config) {
|
||||||
data = json_object_object_get(config, "data");
|
data = json_object_object_get(config, "data");
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -78,7 +78,9 @@ RestIntegerMapT *restHelperConfigIntegerMapGet(json_object *object) {
|
||||||
json_object *item = NULL;
|
json_object *item = NULL;
|
||||||
RestIntegerMapT *result = NULL;
|
RestIntegerMapT *result = NULL;
|
||||||
|
|
||||||
config = json_object_object_get(object, "config");
|
sh_new_strdup(result);
|
||||||
|
|
||||||
|
config = json_object_object_get(object, "payload");
|
||||||
if (config) {
|
if (config) {
|
||||||
data = json_object_object_get(config, "data");
|
data = json_object_object_get(config, "data");
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -109,7 +111,7 @@ char *restHelperConfigStringGet(json_object *object, char *name, char *defaultVa
|
||||||
json_object *item = NULL;
|
json_object *item = NULL;
|
||||||
char *result = strdup(defaultValue);
|
char *result = strdup(defaultValue);
|
||||||
|
|
||||||
config = json_object_object_get(object, "config");
|
config = json_object_object_get(object, "payload");
|
||||||
if (config) {
|
if (config) {
|
||||||
data = json_object_object_get(config, "data");
|
data = json_object_object_get(config, "data");
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -136,7 +138,9 @@ RestStringMapT *restHelperConfigStringMapGet(json_object *object) {
|
||||||
json_object *item = NULL;
|
json_object *item = NULL;
|
||||||
RestStringMapT *result = NULL;
|
RestStringMapT *result = NULL;
|
||||||
|
|
||||||
config = json_object_object_get(object, "config");
|
sh_new_strdup(result);
|
||||||
|
|
||||||
|
config = json_object_object_get(object, "payload");
|
||||||
if (config) {
|
if (config) {
|
||||||
data = json_object_object_get(config, "data");
|
data = json_object_object_get(config, "data");
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -208,10 +212,10 @@ json_object *restRequest(char *command, char *format, ...) {
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
logWrite("Request: %s\n", json_object_to_json_string_ext(request, JSON_C_TO_STRING_PRETTY));
|
//logWrite("Request: %s\n", json_object_to_json_string_ext(request, JSON_C_TO_STRING_PRETTY));
|
||||||
response = restUrlPost(request);
|
response = restUrlPost(request);
|
||||||
json_object_put(request);
|
json_object_put(request);
|
||||||
logWrite("Response: %s\n", json_object_to_json_string_ext(response, JSON_C_TO_STRING_PRETTY));
|
//logWrite("Response: %s\n", json_object_to_json_string_ext(response, JSON_C_TO_STRING_PRETTY));
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
if (json_object_get_boolean(json_object_object_get(response, "result")) != TRUE) {
|
if (json_object_get_boolean(json_object_object_get(response, "result")) != TRUE) {
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define PACKET_MAX 1024 // Maximum number of bytes per packet
|
#define PACKET_MAX 1024 // Maximum number of bytes per packet.
|
||||||
#define PACKET_SEQUENCE_MAX 16 // Five bits of data, 32 max.
|
#define PACKET_SEQUENCE_MAX 32 // Five bits of data, 32 max. Represents size of replay history. Also maximum number of packets on the wire at a time.
|
||||||
|
|
||||||
#define PACKET_INPUT_QUEUE_SIZE 4096
|
#define PACKET_INPUT_QUEUE_SIZE 4096
|
||||||
#define PACKET_BUFFER_SIZE (PACKET_MAX * 2 + 2 + 8) // Worst case, every byte is a PACKET_FRAME. Add two for ending frame. Add 8 for worst case header and CRC.
|
#define PACKET_BUFFER_SIZE (PACKET_MAX * 2 + 2 + 8) // Worst case, every byte is a PACKET_FRAME. Add two for ending frame. Add 8 for worst case header and CRC.
|
||||||
|
|
Loading…
Add table
Reference in a new issue