As general introduction on thread https://community.freescale.com/docs/DOC-328302 , I did a smart LED application with GoKit and FRDM-KL02.
In this design, FRDM-KL02 will communicate with GoKit by WIFI, and control LED flash.
Code Structure
Code Basic Introduction
In this project structure, you need to do following items on code.
You can find my main.c and protocol.c as attachment.
In this document, I would like to detail introduce function MessageHandle(),
void MessageHandle(void)
{
pro_headPart tmp_headPart; //Common command package
memset(&tmp_headPart, 0, sizeof(pro_headPart));
if(get_one_package)
{
get_one_package = 0;
memcpy(&tmp_headPart, uart_buf, sizeof(pro_headPart));
//CRC error, send back error command
if(CheckSum(uart_buf, uart_Count) != uart_buf[uart_Count-1])
{
SendErrorCmd(ERROR_CHECKSUM, tmp_headPart.sn);
return ;
}
So, you can see that only get_one_package=1, we can receive frame completely.
switch(tmp_headPart.cmd)
{
case CMD_GET_MCU_INFO:
CmdGetMcuInfo(tmp_headPart.sn); break;
case CMD_SEND_HEARTBEAT:
SendCommonCmd(CMD_SEND_HEARTBEAT_ACK, tmp_headPart.sn);
break;
case CMD_REBOOT_MCU:
SendCommonCmd(CMD_REBOOT_MCU_ACK, tmp_headPart.sn);
case CMD_SEND_MCU_P0:
CmdSendMcuP0(uart_buf);
break;
case CMD_REPORT_MODULE_STATUS:
CmdReportModuleStatus(uart_buf);
break;
default:
SendErrorCmd(ERROR_CMD, tmp_headPart.sn);
break;
}
}
}
After that, you can do operations mentioned in thread https://community.freescale.com/docs/DOC-328302. You can see smart LED device and been found.