Refactor set SDK connection message constructor
This commit is contained in:
+13
-5
@@ -49,13 +49,21 @@ message_new(struct Client* session, uint8_t cmdset, uint8_t cmdid, size_t length
|
|||||||
|
|
||||||
// public
|
// public
|
||||||
const Message
|
const Message
|
||||||
set_sdk_connection_req_new (
|
set_sdk_connection_req_new(
|
||||||
Client session,
|
Client session,
|
||||||
struct SetSdkConnectionReq* msg ) {
|
enum CONNECTION connection_type,
|
||||||
|
uint32_t ip_address,
|
||||||
|
uint16_t port ) {
|
||||||
|
|
||||||
msg->host = session->hostbyte;
|
const struct SetSdkConnectionReq msg = {
|
||||||
struct Message* message = message_new(session, 0x3F, SET_SDK_CONNECTION_CMDID, sizeof(struct SetSdkConnectionReq), msg);
|
0,
|
||||||
return message;
|
session->hostbyte,
|
||||||
|
connection_type,
|
||||||
|
0,
|
||||||
|
ip_address,
|
||||||
|
port
|
||||||
|
};
|
||||||
|
return message_new(session, 0x3F, SET_SDK_CONNECTION_CMDID, sizeof(msg), &msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Message
|
const Message
|
||||||
|
|||||||
+11
-5
@@ -93,10 +93,6 @@ typedef struct Message* Message;
|
|||||||
|
|
||||||
Client client_new(void* buffer, size_t size);
|
Client client_new(void* buffer, size_t size);
|
||||||
|
|
||||||
static const uint8_t CONNECTION_WIFI_AP = 0;
|
|
||||||
static const uint8_t CONNECTION_WIFI_STA = 1;
|
|
||||||
static const uint8_t CONNECTION_USB_RNDIS = 2;
|
|
||||||
|
|
||||||
// Not sure what these are for, but they are used for the hostbyte
|
// Not sure what these are for, but they are used for the hostbyte
|
||||||
static const uint8_t DEFAULT_CLIENT_HOST = 9;
|
static const uint8_t DEFAULT_CLIENT_HOST = 9;
|
||||||
static const uint8_t DEFAULT_CLIENT_INDEX = 6;
|
static const uint8_t DEFAULT_CLIENT_INDEX = 6;
|
||||||
@@ -115,6 +111,12 @@ static inline void byte2host(uint8_t b, uint8_t* host, uint8_t* index) {
|
|||||||
|
|
||||||
static const uint8_t SET_SDK_CONNECTION_CMDID = 0xD4;
|
static const uint8_t SET_SDK_CONNECTION_CMDID = 0xD4;
|
||||||
|
|
||||||
|
enum CONNECTION {
|
||||||
|
CONNECTION_WIFI_AP = 0,
|
||||||
|
CONNECTION_WIFI_STA = 1,
|
||||||
|
CONNECTION_USB_RNDIS = 2
|
||||||
|
}
|
||||||
|
|
||||||
struct PACKED SetSdkConnectionReq {
|
struct PACKED SetSdkConnectionReq {
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
uint8_t host;
|
uint8_t host;
|
||||||
@@ -130,7 +132,11 @@ struct PACKED SetSdkConnectionResp {
|
|||||||
uint32_t config_ip;
|
uint32_t config_ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Message set_sdk_connection_req_new(Client session, struct SetSdkConnectionReq* msg);
|
const Message set_sdk_connection_req_new(
|
||||||
|
Client session,
|
||||||
|
enum CONNECTION connection_type,
|
||||||
|
uint32_t ip_address,
|
||||||
|
uint16_t port );
|
||||||
|
|
||||||
static const uint8_t GET_VERSION_CMDID = 0x01;
|
static const uint8_t GET_VERSION_CMDID = 0x01;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user