Set SDK port back default removed seq_id bounds
This commit is contained in:
+2
-2
@@ -11,7 +11,7 @@ struct Session* session_new(void* buffer, size_t size) {
|
|||||||
else
|
else
|
||||||
session->buffer = buffer;
|
session->buffer = buffer;
|
||||||
session->size = 0;
|
session->size = 0;
|
||||||
session->seq = RM_SDK_FIRST_SEQ_ID;
|
session->seq = 0;
|
||||||
session->max_size = size;
|
session->max_size = size;
|
||||||
// TODO: Make this configurable
|
// TODO: Make this configurable
|
||||||
session->hostbyte = host2byte(DEFAULT_CLIENT_HOST, DEFAULT_CLIENT_INDEX);
|
session->hostbyte = host2byte(DEFAULT_CLIENT_HOST, DEFAULT_CLIENT_INDEX);
|
||||||
@@ -30,7 +30,7 @@ message_new(struct Session* session, uint8_t cmdset, uint8_t cmdid, size_t lengt
|
|||||||
memcpy((void*)message->body, body, length);
|
memcpy((void*)message->body, body, length);
|
||||||
length += sizeof(struct Header) + sizeof(struct Footer);
|
length += sizeof(struct Header) + sizeof(struct Footer);
|
||||||
session->size += length;
|
session->size += length;
|
||||||
int16_t seq = ++session->seq;
|
int16_t seq = session->seq++;
|
||||||
|
|
||||||
message->header.preamble = 0x55;
|
message->header.preamble = 0x55;
|
||||||
message->header.length_l = length & 0xFF;
|
message->header.length_l = length & 0xFF;
|
||||||
|
|||||||
@@ -74,10 +74,6 @@ Session session_new(void* buffer, size_t size);
|
|||||||
|
|
||||||
size_t session_size(Session session);
|
size_t session_size(Session session);
|
||||||
|
|
||||||
// SEQ ID will loop around
|
|
||||||
static const int16_t RM_SDK_FIRST_SEQ_ID = 11239;
|
|
||||||
static const int16_t RM_SDK_LAST_SEQ_ID = 20000;
|
|
||||||
|
|
||||||
static const uint8_t CONNECTION_WIFI_AP = 0;
|
static const uint8_t CONNECTION_WIFI_AP = 0;
|
||||||
static const uint8_t CONNECTION_WIFI_STA = 1;
|
static const uint8_t CONNECTION_WIFI_STA = 1;
|
||||||
static const uint8_t CONNECTION_USB_RNDIS = 2;
|
static const uint8_t CONNECTION_USB_RNDIS = 2;
|
||||||
|
|||||||
+2
-7
@@ -16,8 +16,7 @@ int main(int argc, char* argv[])
|
|||||||
req.connection = CONNECTION_WIFI_AP;
|
req.connection = CONNECTION_WIFI_AP;
|
||||||
req.protocol = 0;
|
req.protocol = 0;
|
||||||
req.ip_address = 0;
|
req.ip_address = 0;
|
||||||
//req.port = 10010;
|
req.port = 10010;
|
||||||
req.port = 10242;
|
|
||||||
const Message msg = set_sdk_connection_req_new(session, &req);
|
const Message msg = set_sdk_connection_req_new(session, &req);
|
||||||
|
|
||||||
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
@@ -43,14 +42,10 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// check footer crc
|
// check footer crc
|
||||||
uint16_t expected_crc16 = crc16(recvbuff, recvb - 2);
|
uint16_t expected_crc16 = crc16(recvbuff, recvb - 2);
|
||||||
uint16_t actual_crc16 = ntohs(*(uint16_t*)(recvbuff + recvb - 2));
|
uint16_t actual_crc16 = *(uint16_t*)(recvbuff + recvb - 2);
|
||||||
if(actual_crc16 != expected_crc16)
|
if(actual_crc16 != expected_crc16)
|
||||||
fprintf(stderr, "expected crc16 %d got %d", actual_crc16, expected_crc16);
|
fprintf(stderr, "expected crc16 %d got %d", actual_crc16, expected_crc16);
|
||||||
|
|
||||||
// check hostbyte
|
|
||||||
if(resp->header.receiver != session->hostbyte)
|
|
||||||
fprintf(stderr, "expected receiver %d got %d", session->hostbyte, resp->header.receiver);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user