Chat freely about anything...

User avatar
By Masoud Navidi
#91448 Hi everyone.
I have a station connected to my ESP and I want to send the numbers (0x53, 0x54) to it.
I'm using AT COMMANDs and my data is stored in cycle_table.
I have tried the code below with no success:

Code: Select allvoid SendCommand(UART_HandleTypeDef *huart, uint8_t PacketLength){
   
   char Command [30];
   for(uint8_t m = 0; m < 4; m++){   
      
      sprintf(Command, "AT+CIPSEND=");
      
      DebugPrintln(huart, Command);
      
      HAL_UART_Transmit(huart, &m, 1, 10);
      
      HAL_UART_Transmit(huart, (uint8_t *) 0x2C, 1, 10);
      
      if(PacketLength>=10){
         HAL_UART_Transmit(huart, (uint8_t *) ((PacketLength/10)+0x30), 1, 10);
         HAL_UART_Transmit(huart, (uint8_t *) ((PacketLength%10)+0x30), 1, 10);
      }
      else{
         HAL_UART_Transmit(huart, (uint8_t *) (PacketLength+0x30), 1, 10);
      }
      
      char NewLine[2] = "\r\n";
      HAL_UART_Transmit(huart, (uint8_t *) NewLine, 2, 10);
      
      HAL_Delay(100);
      
      for(int n = 0; n < PacketLength; n++){
         
         HAL_UART_Transmit(huart, &cycle_table[n], 1, 10);
         
      }
   }
}

void DebugPrintln(UART_HandleTypeDef *huart, char _out[]){
   HAL_UART_Transmit(huart, (uint8_t *) _out, strlen(_out), 10);
   char NewLine[2] = "\r\n";
   HAL_UART_Transmit(huart, (uint8_t *) NewLine, 2, 10);
}