pinebuds/services/communication/comminication_knowles/communication_cmd_handle.cpp
Ben V. Brown 75381150fd Formatting
Formatting Pass 1

Lots of fixups to adding stdint and stdbool all over the place

Formatting Pass 2
Formatting Pass 3
Formatting Pass 4

Update app_bt_stream.cpp
2023-02-02 07:56:49 +11:00

69 lines
1.7 KiB
C++

#include "communication_cmd_handle.h"
#include "hal_chipid.h"
#include "hal_dma.h"
#include "hal_trace.h"
#include "plat_types.h"
#include "stdbool.h"
#include "stdint.h"
#include "string.h"
static bool communication_cmd_inited = false;
static int (*send_reply_cb)(const unsigned char *, unsigned int);
extern "C" int extend_cmd_pmu_open(void);
int communication_cmd_init(int (*cb)(const unsigned char *, unsigned int)) {
if (!communication_cmd_inited) {
send_reply_cb = cb;
communication_cmd_inited = true;
}
return 0;
}
int communication_cmd_send_reply(const unsigned char *payload,
unsigned int len) {
return send_reply_cb(payload, len);
}
enum ERR_CODE communication_cmd_check_msg_hdr(struct message_t *msg) {
return ERR_NONE;
}
void FloatToByte(float floatNum, unsigned char *byteArry) {
char *pchar = (char *)&floatNum;
for (u32 i = 0; i < sizeof(float); i++) {
*byteArry = *pchar;
pchar++;
byteArry++;
}
}
enum ERR_CODE communication_cmd_handle_cmd(enum COMMUNICATION_CMD_TYPE cmd,
unsigned char *param,
unsigned int len) {
enum ERR_CODE nRet = ERR_NONE;
// uint8_t cret[5]={0x01,0x02,0x03,0x04,0x05};
// cret[0] = ERR_NONE;
TRACE(1, "###communication_cmd_handle_cmd,len=%d", len);
switch (cmd) {
case COMMUNICATION_CMD_EQ_OP: {
#ifdef __PC_CMD_UART__
// DUMP8("%02x ",param,len);
communication_cmd_send_reply(param, len);
#endif
} break;
case COMMUNICATION_CMD_DRC_OP: {
} break;
case COMMUNICATION_CMD_HF_OP: {
} break;
default: {
TRACE(1, "Invalid command: 0x%x", cmd);
nRet = ERR_INTERNAL;
}
}
// communication_cmd_send_reply(cret,10);
return nRet;
}