示例#1
0
bool lib_aci_send_data(uint8_t pipe, uint8_t *p_value, uint8_t size)
{
  bool ret_val = false;
  aci_cmd_params_send_data_t aci_cmd_params_send_data;

  
  if(!((p_services_pipe_type_map[pipe-1].pipe_type == ACI_TX) ||
      (p_services_pipe_type_map[pipe-1].pipe_type == ACI_TX_ACK)))
  {
    return false;
  }

  if (size > ACI_PIPE_TX_DATA_MAX_LEN)
  {
    return false;
  }
  {
      aci_cmd_params_send_data.tx_data.pipe_number = pipe;
      memcpy(&(aci_cmd_params_send_data.tx_data.aci_data[0]), p_value, size);
      acil_encode_cmd_send_data(&(msg_to_send.buffer[0]), &aci_cmd_params_send_data, size);
      
      ret_val = hal_aci_tl_send(&msg_to_send);          
  }
  return ret_val;
}
示例#2
0
文件: acilib.cpp 项目: chihchun/upm
bool acil_encode_cmd(uint8_t *buffer, aci_cmd_t *p_aci_cmd)
{
  bool ret_val = false;

  switch(p_aci_cmd->cmd_opcode)
  {
    case ACI_CMD_TEST:
      acil_encode_cmd_set_test_mode(buffer, &(p_aci_cmd->params.test));
      break;
    case ACI_CMD_SLEEP:
      acil_encode_cmd_sleep(buffer);
      break;
    case ACI_CMD_GET_DEVICE_VERSION:
      acil_encode_cmd_get_device_version(buffer);
      break;
    case ACI_CMD_WAKEUP:
      acil_encode_cmd_wakeup(buffer);
      break;
    case ACI_CMD_ECHO:
      acil_encode_cmd_echo_msg(buffer, &(p_aci_cmd->params.echo), (p_aci_cmd->len - MSG_ECHO_MSG_CMD_BASE_LEN));
      break;
    case ACI_CMD_GET_BATTERY_LEVEL:
      acil_encode_cmd_battery_level(buffer);
      break;
    case ACI_CMD_GET_TEMPERATURE:
      acil_encode_cmd_temparature(buffer);
      break;
    case ACI_CMD_GET_DEVICE_ADDRESS:
      acil_encode_cmd_get_address(buffer);
      break;
    case ACI_CMD_SET_TX_POWER:
      acil_encode_cmd_set_radio_tx_power(buffer, &(p_aci_cmd->params.set_tx_power));
      break;
    case ACI_CMD_CONNECT:
      acil_encode_cmd_connect(buffer, &(p_aci_cmd->params.connect));
      break;
    case ACI_CMD_BOND:
      acil_encode_cmd_bond(buffer, &(p_aci_cmd->params.bond));
      break;
    case ACI_CMD_DISCONNECT:
      acil_encode_cmd_disconnect(buffer, &(p_aci_cmd->params.disconnect));
      break;
    case ACI_CMD_RADIO_RESET:
      acil_encode_baseband_reset(buffer);
      break;
    case ACI_CMD_CHANGE_TIMING:
      acil_encode_cmd_change_timing_req(buffer, &(p_aci_cmd->params.change_timing));
      break;
    case ACI_CMD_SETUP:
      acil_encode_cmd_setup(buffer, &(p_aci_cmd->params.setup), (p_aci_cmd->len - MSG_SETUP_CMD_BASE_LEN));
      break;
    case ACI_CMD_DTM_CMD:
      acil_encode_cmd_dtm_cmd(buffer, &(p_aci_cmd->params.dtm_cmd));
      break;
    case ACI_CMD_READ_DYNAMIC_DATA:
      acil_encode_cmd_read_dynamic_data(buffer);
      break;
    case ACI_CMD_WRITE_DYNAMIC_DATA:
      acil_encode_cmd_write_dynamic_data(buffer, p_aci_cmd->params.write_dynamic_data.seq_no, &(p_aci_cmd->params.write_dynamic_data.dynamic_data[0]), (p_aci_cmd->len - MSG_WRITE_DYNAMIC_DATA_BASE_LEN));
      break;
    case ACI_CMD_OPEN_REMOTE_PIPE:
      acil_encode_cmd_open_remote_pipe(buffer, &(p_aci_cmd->params.open_remote_pipe));
      break;
    case ACI_CMD_SEND_DATA:
      acil_encode_cmd_send_data(buffer, &(p_aci_cmd->params.send_data), (p_aci_cmd->len - MSG_SEND_DATA_BASE_LEN));
      break;
    case ACI_CMD_SEND_DATA_ACK:
      acil_encode_cmd_send_data_ack(buffer, p_aci_cmd->params.send_data_ack.pipe_number );
      break;
    case ACI_CMD_REQUEST_DATA:
      acil_encode_cmd_request_data(buffer, &(p_aci_cmd->params.request_data));
      break;
    case ACI_CMD_SET_LOCAL_DATA:
      acil_encode_cmd_set_local_data(buffer, (aci_cmd_params_set_local_data_t *)(&(p_aci_cmd->params.send_data)), (p_aci_cmd->len - MSG_SET_LOCAL_DATA_BASE_LEN));
      break;
    case ACI_CMD_BOND_SECURITY_REQUEST:
      acil_encode_cmd_bond_security_request(buffer);
      break;
    default:
      break;
  }
  return ret_val;
}