#include "RGB_Sensor.h"



#define     RGB_ControllerID_SET_Length 10 
#define     RGB_SensorID_SET_Length     10 
#define     RGB_SensorDataRequest_Length 7
#define     RGB_SensorIDAutoSetRequest_Length 7

uint8_t My_RGB_ID = 0;
uint8_t* RGB_Sensor_Func(uint8_t* data){
	RGB_CMD_T type = data[Bluecell_Type];
    switch(type){
        case RGB_Status_Data_Request:      
            if(data[blucell_srcid + 1] == My_RGB_ID){
                 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_SET);
                printf("MY RGB Status Send");
                for(uint8_t i = 0; i<15; i++)
                    printf("%02x ",RGB_Data[i]);
                printf(
"\r\n");
                Uart2_Data_Send(&RGB_Data[0],15);
                 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_RESET);
            }else{
                printf("NO MY ID\r\n");
            }
            break;
        case RGB_ControllerID_SET:                             break;
        case RGB_SensorID_SET:    
            if(My_RGB_ID == 0){
                HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_SET);
                data[blucell_type] = RGB_SensorID_SET_Success;
                data[blucell_length + 1] = My_RGB_ID = data[blucell_length + 2];
                data[5]   = STH30_CreateCrc(&data[blucell_type],data[blucell_length]);
                printf("My ID SET Success %02x \r\n",My_RGB_ID);
                Uart2_Data_Send(&data[blucell_stx],RGB_SensorIDAutoSetRequest_Length);
                HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_RESET);
            }else{
                printf("My ID already exists.  %02x \r\n",My_RGB_ID);
                
            }
            break;
        default:break;
    }
    return data;
}
void RGB_Value_Func(void){
    
}
