/** * ¸Ä±äµÆ¹âµÄº¯Êý£¬phoneStatus ÊÖ»ú״̬£¬isChange ÊÇ·ñ²¥·ÅÇл»Ð§¹û¡£ * phoneStatus = -2 ±íʾ¶ÁÈ¡µ½ÁËcharacteristic1 µÄÊý×éÖµ¡£ * phoneStatus = -1 ±íʾ¶ÁÈ¡µ½ÁËcharacteristic2 µÄÊý×éÖµ¡£ */ static void dataChange(int8 phoneStatus,uint8 isChange){ HalLcdWriteStringValue( "phoneStatus +£º", phoneStatus, 10, HAL_LCD_LINE_7 ); uint8 newValueBuf[20]={0}; SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, newValueBuf ); //Ö»¶ÁÈ¡µ½Êý×é1µÄÊý¾Ý£¬ÏȲ»¸Ä±äµÆ¹âÖ»¼Ç¼ÏÂÀ´£¬µÈÊý×é2µÄÊý¾Ý±»¶Áµ½ºó²Å½øÐеƹâ¸Ä±äµÄ²Ù×÷¡£ if(phoneStatus == -2){ //HalLcdWriteStringValue( "Char 1:", newValueBuf[0], 10, HAL_LCD_LINE_3 ); init_QI_Switch(newValueBuf[1]); return; } uint8 newValueBuf2[20]={0}; SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR2, newValueBuf2 ); //newValueBuf[0] = 1; if(phoneStatus >=0){ newValueBuf[0] = phoneStatus; //HalLcdWriteStringValue( "change:", newValueBuf[13], 10, HAL_LCD_LINE_4 ); //HalLcdWriteStringValue( "change:", newValueBuf[16], 10, HAL_LCD_LINE_5 ); } HalLcdWriteStringValue( "status:", newValueBuf[0], 10, HAL_LCD_LINE_6 ); if(newValueBuf[0] != 16){ //дÈëµ½flashÖÐ osal_snv_write(0x80,20,newValueBuf); osal_snv_write(0x95,20,newValueBuf2); } //¸Ä±äµÈÑÕÉ« setValus(newValueBuf,newValueBuf2,isChange); LedChange(); }
/********************************************************************* * @fn SimpleBLEPeripheral_processCharValueChangeEvt * * @brief Process a pending Simple Profile characteristic value change * event. * * @param paramID - parameter ID of the value that was changed. * * @return None. */ static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID) { #ifndef FEATURE_OAD_ONCHIP uint8_t newValue; switch(paramID) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, &newValue); Display_print1(dispHandle, 4, 0, "Char 1: %d", (uint16_t)newValue); break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue); Display_print1(dispHandle, 4, 0, "Char 3: %d", (uint16_t)newValue); break; default: // should not reach here! break; } #endif //!FEATURE_OAD_ONCHIP }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 newValue; switch( paramID ) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue ); //存储mp,校准是需要重新写入measured power osal_snv_write(0xfe,1,&newValue); //通知重启 osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 1:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &newValue ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 3:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) break; default: // should not reach here! break; } }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 newValue; switch( paramID ) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 1:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &newValue ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 3:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) break; default: // should not reach here! break; } }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 data[20]; uint8 len; switch( paramID ) { case SIMPLEPROFILE_CHAR1: //SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue ); break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &data ); len = data[0]; UART_SEND_DEBUG_MSG(&data[1], len); // << Wayne >> << RepeatCmd >> ++ if(repeatCmdSendData(&data[1], len)) // << Wayne >> << RepeatCmd >> -- { // << Wayne >> << dBCmd Service >> ++ dBCommand_Service(&data[1]); // << Wayne >> << dBCmd Service >> -- } break; case SIMPLEPROFILE_CHAR5: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR5, &data ); timeAppClockSet(&data[0]); break; default: // should not reach here! break; } }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 newValue; switch( paramID ) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue ); ECGRate = newValue; Reset_ADS1194_Mode(ECGRate,ECGGain); // ADS1194_Init(ECGRate,ECGGain); break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &newValue ); ECGGain = newValue; Reset_ADS1194_Mode(ECGRate,ECGGain); // ADS1194_Init(ECGRate,ECGGain); break; default: // should not reach here! break; } }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 newValue, intval[3]; switch( paramID ) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 1:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) //发射功率有四个级别,-23dbm,-6dbm,0dbm, 4dbm, newValue为0~3,当连接的时候,只能设置-6, 0 if(newValue == LL_EXT_TX_POWER_MINUS_6_DBM || newValue == LL_EXT_TX_POWER_0_DBM) { HCI_EXT_SetTxPowerCmd(newValue); ProxReporter_SetParameter( PP_TX_POWER_LEVEL, sizeof ( int8 ), &newValue ); } break; case SIMPLEPROFILE_CHAR2: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR2, &newValue ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 2:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) if( newValue == 1 && gOpenDoorStep == 0 ){ gOpenDoorStep++; osal_set_event( simpleBLEPeripheral_TaskID, SBP_OPENDOOR_DEVICE_EVT ); } break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, intval ); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 3:", (uint16)(newValue), 10, HAL_LCD_LINE_3 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) advert_internal = (intval[0] - 0x30) *100 + (intval[1] - 0x30) * 10 + (intval[2] - 0x30); break; default: // should not reach here! break; } }
/********************************************************************* * @fn performPeriodicTask * * @brief Perform a periodic application task. This function gets * called every five seconds as a result of the SBP_PERIODIC_EVT * OSAL event. In this example, the value of the third * characteristic in the SimpleGATTProfile service is retrieved * from the profile, and then copied into the value of the * the fourth characteristic. * * @param none * * @return none */ static void performPeriodicTask( void ) { uint8 valueToCopy; uint8 stat; static attHandleValueNoti_t pReport; pReport.len = 2; pReport.handle = 0x2E; osal_memcpy(pReport.value, "ab", 2); GATT_Notification( 0, &pReport, FALSE ); // Call to retrieve the value of the third characteristic in the profile stat = SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &valueToCopy); if( stat == SUCCESS ) { /* * Call to set that value of the fourth characteristic in the profile. Note * that if notifications of the fourth characteristic have been enabled by * a GATT client device, then a notification will be sent every time this * function is called. */ SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy); } }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 Value[SIMPLEPROFILE_CHAR6_LEN] = {0}; char6_t char6; switch( paramID ) { case SIMPLEPROFILE_CHAR1: break; case SIMPLEPROFILE_CHAR2: break; case SIMPLEPROFILE_CHAR3: break; case SIMPLEPROFILE_CHAR5: break; case SIMPLEPROFILE_CHAR6: SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR6, Value ); osal_memcpy(char6.pwd, Value, 6); char6.id = Value[6]; char6.cmd = Value[7]; char6.res = Value[8]; osal_memcpy(char6.num, Value + 9, 6); executive_cmd(char6); break; default: // should not reach here! break; } }
/********************************************************************* * @fn simpleTopology_processCharValueChangeEvt * * @brief Process a pending Simple Profile characteristic value change * event. * * @param paramID - parameter ID of the value that was changed. * * @return None. */ static void simpleTopology_processCharValueChangeEvt(uint8_t paramID) { uint8_t newValue; switch(paramID) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, &newValue); LCD_WRITE_STRING_VALUE("Char 1:", (uint16_t)newValue, 10, LCD_PAGE4); break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue); LCD_WRITE_STRING_VALUE("Char 3:", (uint16_t)newValue, 10, LCD_PAGE4); break; default: // should not reach here! break; } }
/********************************************************************* * @fn trainingTag_processCharValueChangeEvt * * @brief Process a pending Simple Profile characteristic value change * event. * * @param paramID - parameter ID of the value that was changed. * * @return None. */ static void trainingTag_processCharValueChangeEvt(uint8_t paramID) { uint8_t newValue; switch(paramID) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, &newValue); System_printf("Char 1: 0x%x\r\n", newValue); break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue); System_printf("Char 3: 0x%x\r\n", newValue); break; default: // should not reach here! break; } }
/********************************************************************* * @fn trainingTag_performPeriodicTask * * @brief Perform a periodic application task. This function gets called * every five seconds (TTG_PERIODIC_EVT_PERIOD). In this example, * the value of the third characteristic in the SimpleGATTProfile * service is retrieved from the profile, and then copied into the * value of the the fourth characteristic. * * @param None. * * @return None. */ static void trainingTag_performPeriodicTask(void) { uint8_t valueToCopy; // Call to retrieve the value of the third characteristic in the profile if (SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &valueToCopy) == SUCCESS) { // Call to set that value of the fourth characteristic in the profile. // Note that if notifications of the fourth characteristic have been // enabled by a GATT client device, then a notification will be sent // every time this function is called. SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t), &valueToCopy); } }
/********************************************************************* * @fn performPeriodicTask * * @brief Perform a periodic application task. This function gets * called every five seconds as a result of the SBP_PERIODIC_EVT * OSAL event. In this example, the value of the third * characteristic in the SimpleGATTProfile service is retrieved * from the profile, and then copied into the value of the * the fourth characteristic. * * @param none * * @return none */ static void performPeriodicTask(void) { uint8 valueToCopy; uint8 stat; // Call to retrieve the value of the third characteristic in the profile stat = SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &valueToCopy); if (stat == SUCCESS) { /* * Call to set that value of the fourth characteristic in the profile. Note * that if notifications of the fourth characteristic have been enabled by * a GATT client device, then a notification will be sent every time this * function is called. */ SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy); } }
static void performPeriodicTask( void ) { //static bool a = true; //a = !a; //HalLedSet(HAL_LED_1,a); #if 0 char strTemp[35] = {0}; sprintf(strTemp, "led1 = %d\r\n",a); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif if ( simpleBLEState == BLE_STATE_CONNECTED && simpleBLEProcedureInProgress == FALSE ) { uint8 status; attReadReq_t req; req.handle = simpleBLECharHdl; status = GATT_ReadCharValue( simpleBLEConnHandle, &req, simpleBLETaskId ); #if 0 sprintf(strTemp, "read status = %d\r\n",status); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif } #if 0 uint8 valueToCopy; uint8 stat; // Call to retrieve the value of the third characteristic in the profile stat = SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &valueToCopy); if( stat == SUCCESS ) { /* * Call to set that value of the fourth characteristic in the profile. Note * that if notifications of the fourth characteristic have been enabled by * a GATT client device, then a notification will be sent every time this * function is called. */ SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy); } #endif }
/********************************************************************* * @fn performPeriodicTask * * @brief Perform a periodic application task. This function gets * called every five seconds as a result of the SBP_PERIODIC_EVT * OSAL event. In this example, the value of the third * characteristic in the SimpleGATTProfile service is retrieved * from the profile, and then copied into the value of the * the fourth characteristic. * * @param none * * @return none */ static void performPeriodicTask( void ) { uint8 data[20]; SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR2, SIMPLEPROFILE_CHAR2_LEN, randomGen_Max20bytes(SIMPLEPROFILE_CHAR2_LEN) ); SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR2, &data ); //data[1] = exchange_DHM(data); //SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR2, SIMPLEPROFILE_CHAR2_LEN, data); attHandleValueNoti_t noti; //dummy handle noti.handle = 0x28; noti.len = 20; uint8 i; for (i= 0; i < 20; i++) { noti.value[i] = data[i]; } GATT_Notification(0, ¬i, FALSE); //uint8 valueToCopy = 0x08; //uint8 stat; // //Call to retrieve the value of the third characteristic in the profile //stat = SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &valueToCopy); //if( stat == SUCCESS ) //{ /* * Call to set that value of the fourth characteristic in the profile. Note * that if notifications of the fourth characteristic have been enabled by * a GATT client device, then a notification will be sent every time this * function is called. */ // SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy); //} }
/********************************************************************* * @fn simpleProfileChangeCB * @brief Callback from SimpleBLEProfile indicating a value change * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB(uint8 paramID) { osal_memset(newValueBuf, 0, 20); switch (paramID) { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, newValueBuf); if ((newValueBuf[0] == TRANSFER_DATA_SIGN) && (newValueBuf[1] == TRANSFER_DATA_SIGN_RE)) { TRANSFER_DATA_STATE_IN = FALSE; } if ((newValueBuf[2] != 0) && (!TRANSFER_DATA_STATE_IN)) { data_len = newValueBuf[UART_DATA_START_INDEX]; TRANSFER_DATA_STATE_IN = TRUE; data_len_index = 0; osal_memset(recv_value, 0, data_len); } cur_data_len = osal_strlen(newValueBuf); if (TRANSFER_DATA_STATE_IN) { osal_memcpy((recv_value + data_len_index), newValueBuf, cur_data_len); data_len_index += cur_data_len; if ((data_len_index - send_times * one_time_data_len - UART_DATA_START_INDEX) >= one_time_data_len) { if (send_times == 0) { recv_value[UART_DATA_START_INDEX] = 0xE3; if (u_state != IR_DATA_SEND_BEGIN_STATE) { u_state = IR_DATA_SEND_BEGIN_STATE; SbpHalUARTWrite(recv_value + UART_DATA_START_INDEX, one_time_data_len); } } else { SbpHalUARTWrite(recv_value + UART_DATA_START_INDEX + send_times * one_time_data_len, one_time_data_len); } send_times++; } else if ((send_times > 0) && ((data_len_index - send_times * one_time_data_len) < one_time_data_len) && (data_len_index == data_len)) { SbpHalUARTWrite(recv_value + UART_DATA_START_INDEX + send_times * one_time_data_len, data_len - send_times * one_time_data_len - UART_DATA_START_INDEX); send_times++; } else if ((send_times == 0) && (data_len < one_time_data_len) && (data_len_index == data_len)) { recv_value[UART_DATA_START_INDEX] = 0xE3; if (u_state != IR_DATA_SEND_BEGIN_STATE) { u_state = IR_DATA_SEND_BEGIN_STATE; SbpHalUARTWrite(recv_value + UART_DATA_START_INDEX, data_len - UART_DATA_START_INDEX); } } else { } } HalLcdWriteStringValue("data_len_index:", data_len_index, 10, HAL_LCD_LINE_7); if (data_len_index == data_len) { TRANSFER_DATA_STATE_IN = FALSE; HalLcdWriteStringValue("data_len:", osal_strlen((char *)recv_value), 10, HAL_LCD_LINE_6); send_times = 0; data_len = 0; cur_data_len = 0; data_len_index = 0; osal_memset(recv_value, 0, data_len); } break; case SIMPLEPROFILE_CHAR3: //SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue); break; default: // should not reach here! break; } }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 newValue[20]; uint8 returnBytes; switch( paramID ) { case SIMPLEPROFILE_CHAR1: // 收到 CHAR1 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue, &returnBytes); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 1:", (uint16)(newValue[0]), 10, HAL_LCD_LINE_5 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) HalLedBlink (HAL_LED_1, 1, 50, 100);//这个的意思是, 100ms内,以50%的占空比闪烁1次, 实际就是点亮50ms break; case SIMPLEPROFILE_CHAR5: // 收到 CHAR5 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR5, &newValue, &returnBytes); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 5[0]:", (uint16)(newValue[0]), 16, HAL_LCD_LINE_5 ); HalLcdWriteStringValue( "Char 5[1]:", (uint16)(newValue[1]), 16, HAL_LCD_LINE_6 ); HalLcdWriteStringValue( "Char 5[2]:", (uint16)(newValue[2]), 16, HAL_LCD_LINE_7 ); HalLcdWriteStringValue( "Char 5[3]:", (uint16)(newValue[3]), 16, HAL_LCD_LINE_8 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) // 设定温度更新时间, 注意高位在前 if(returnBytes == 4) { sys_config.update_time_ms = (uint32)newValue[0]<<24 | (uint32)newValue[1]<<16| (uint32)newValue[2]<<8| (uint32)newValue[3]; osal_snv_write(0x80, sizeof(SYS_CONFIG), &sys_config); // 写所有参数 if(sys_config.update_time_ms > 0) { osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_READ_SENSOR_EVT, sys_config.update_time_ms); } else { osal_stop_timerEx( simpleBLEPeripheral_TaskID, SBP_READ_SENSOR_EVT); } } HalLedBlink (HAL_LED_2, 1, 50, 100);//这个的意思是, 100ms内,以50%的占空比闪烁1次, 实际就是点亮50ms break; case SIMPLEPROFILE_CHAR6: // 这个是我们添加char6, 用于做串口透传 与从机 notify 数据到主机 很合适 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR6, &newValue, &returnBytes); { char str[21]={0}; char str2[32]={0}; osal_memcpy(str, newValue, returnBytes); sprintf(str2,"Char 6: %s", str); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteString(str2, HAL_LCD_LINE_6 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) // 通过串口透传出去,达到透传目的,amo家的透传就是使用 CHAR6 NPI_WriteTransport(newValue, returnBytes); HalLedBlink (HAL_LED_3, 1, 50, 100);//这个的意思是, 100ms内,以50%的占空比闪烁1次, 实际就是点亮50ms } break; case SIMPLEPROFILE_CHAR7: // 收到 CHAR7 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR7, &newValue, &returnBytes); osal_memset(sys_config.name, 0, sizeof(sys_config.name)); osal_memcpy(sys_config.name, newValue, returnBytes); osal_snv_write(0x80, sizeof(SYS_CONFIG), &sys_config); // 写所有参数 HalLcdWriteString( "Char 7 Set", HAL_LCD_LINE_4 ); HalLcdWriteString( (char*)sys_config.name, HAL_LCD_LINE_5 ); // 需要重启后设备名生效 break; case SIMPLEPROFILE_CHAR8: // 收到 CHAR8 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR8, &newValue, &returnBytes); // 最高温度报警 sys_config.tempeature_hight = newValue[0]<<8; sys_config.tempeature_hight |= newValue[1]; // 最低温度报警 sys_config.tempeature_low = newValue[2]<<8; sys_config.tempeature_low |= newValue[3]; break; case SIMPLEPROFILE_CHAR9: // adc 只读 break; case SIMPLEPROFILE_CHARA: // // pwm SimpleProfile_GetParameter( SIMPLEPROFILE_CHARA, &newValue, &returnBytes); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char A[0]:", (uint16)(newValue[0]), 16, HAL_LCD_LINE_5 ); HalLcdWriteStringValue( "Char A[1]:", (uint16)(newValue[1]), 16, HAL_LCD_LINE_6 ); HalLcdWriteStringValue( "Char A[2]:", (uint16)(newValue[2]), 16, HAL_LCD_LINE_7 ); HalLcdWriteStringValue( "Char A[3]:", (uint16)(newValue[3]), 16, HAL_LCD_LINE_8 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) // 设定pwm if(returnBytes == 4) { sys_config.pwm[3] = newValue[0]; // 白色 sys_config.pwm[2] = newValue[1]; // 红色 sys_config.pwm[1] = newValue[2]; // 绿色 sys_config.pwm[0] = newValue[3]; // 蓝色 osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_SET_PWM_EVT, 50); } break; default: // should not reach here! break; } }