StdPJ/Core/Src/APP/BSP/ug96/ug96.c
/**
  * @brief  Send an amount data over C2C.
  * @param  Obj: pointer to module handle
  * @param  Socket: number of the socket
  * @param  pdata: pointer to data
  * @param  Reqlen : (IN) nr of bytes to be sent
  * @param  SentLen : (OUT) ptr to return the nr of bytes actually sent
  * @param  Timeout : time (ms) for the modem to confirm the data was sent. Function can take twice to return.
  * @retval Operation Status.
  */
@brief  Send an amount data over C2C.
@brief Send an amount data over C2C .
UG96_SendRet_t  UG96_SendData(Ug96Object_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen , uint16_t *SentLen , uint32_t Timeout)
{
  UG96_SendRet_t ret = UG96_SEND_RET_CONN_ERR;
  int32_t cmdret = 0;
  *SentLen = 0;
  if(Reqlen <= UG96_TX_DATABUF_SIZE )
  {
    snprintf(CmdString, 24, "AT+QISEND=%d,%d\r\n", Socket, Reqlen);
    cmdret = AT_ExecuteCommand(Obj, Timeout,  (uint8_t *) CmdString, RET_ERROR | RET_ARROW);
    if(cmdret == RET_ARROW)
    {
      ret = AT_RequestSendData(Obj, pdata, Reqlen, Timeout);
      if(ret == RET_SENT)
      {
        *SentLen =  Reqlen;
      }
    }
    else
    {
#ifdef UG96_DBG
      printf("AT_ExecuteCommand() failed: %ld.\n", cmdret);
#endif
    }
  }
#ifdef UG96_DBG
  if(ret == RET_SENT)
  {
    printf("                UG96_SendData() OK sending from STM32 to UG96: length: %u \n", Reqlen);
  }
  else
  {
    printf("                UG96_SendData() FAIL sending: length: %u, ret error: %d\n", Reqlen, ret);
  }
#endif
  return ret;
}
UG96_SendRet_t UG96_SendData ( Ug96Object_t * Obj , uint8_t Socket , uint8_t * pdata , uint16_t Reqlen , uint16_t * SentLen , uint32_t Timeout ) { UG96_SendRet_t ret = UG96_SEND_RET_CONN_ERR ; int32_t cmdret = 0 ; * SentLen = 0 ; if ( Reqlen <= UG96_TX_DATABUF_SIZE ) { snprintf ( CmdString , 24 , " \r \n " , Socket , Reqlen ) ; cmdret = AT_ExecuteCommand ( Obj , Timeout , ( uint8_t * ) CmdString , RET_ERROR | RET_ARROW ) ; if ( cmdret == RET_ARROW ) { ret = AT_RequestSendData ( Obj , pdata , Reqlen , Timeout ) ; if ( ret == RET_SENT ) { * SentLen = Reqlen ; } } else { #ifdef UG96_DBG printf ( " \n " , cmdret ) ; #endif } } #ifdef UG96_DBG if ( ret == RET_SENT ) { printf ( " \n " , Reqlen ) ; } else { printf ( " \n " , Reqlen , ret ) ; } #endif return ret ; }
@brief  Send an amount data over C2C.
@brief Send an amount data over C2C .