public static Create ( APCommand cmd, byte data ) : |
||
cmd | APCommand | packet command |
data | byte | data to transfer |
리턴 |
/// <summary> /// Get sync buffer status from RF access point /// </summary> /// <param name="status"></param> /// <returns></returns> public bool GetSyncBufferStatus(out SyncStatus status) { Packet response = SendAndReceive(Packet.Create(APCommand.BM_SYNC_GET_BUFFER_STATUS, null), 1, 0); status = (SyncStatus)response.Data[Constants.PACKET_DATA_START]; return(CheckResponse(response)); }
/// <summary> /// Send command packet to watch, wait a given time, and receive a packet with a given length /// </summary> /// <param name="data"></param> /// <returns></returns> public bool SendSyncCommand(byte[] data, int rcvlength, int delay) { if (data.Length > Constants.BM_SYNC_DATA_LEN) { return(false); } Packet response = SendAndReceive(Packet.Create(APCommand.BM_SYNC_SEND_COMMAND, data), rcvlength, delay); return(CheckResponse(response)); }
/// <summary> /// Get generic hardware status /// </summary> /// <param name="status"> /// Returns one of the following values: /// HW_IDLE, HW_SIMPLICITI_STOPPED, HW_SIMPLICITI_TRYING_TO_LINK, HW_SIMPLICITI_LINKED, /// HW_BLUEROBIN_STOPPED, HW_BLUEROBIN_TRANSMITTING, HW_ERROR, HW_NO_ERROR, HW_NOT_CONNECTED /// </param> /// <returns></returns> public bool GetAPStatus(out APStatus status) { byte[] data = new byte[1] { 0x00 }; Packet response = SendAndReceive(Packet.Create(APCommand.BM_GET_STATUS, data), data.Length, 1); status = (APStatus)response.Data[Constants.PACKET_DATA_START]; return(CheckResponse(response)); }
/// <summary> /// Reset RF access point /// </summary> /// <returns></returns> public bool ResetAP() { // can't realize why there is sent a zero byte and received one byte which isn't used, // but it's written this way in the c++ lib byte[] data = new byte[1] { 0x00 }; Packet response = SendAndReceive(Packet.Create(APCommand.BM_RESET, data), data.Length, 1); return(CheckResponse(response)); }
/// <summary> /// Read data bytes from sync buffer /// </summary> /// <param name="data"></param> /// <returns></returns> public bool ReadSyncBuffer(out byte[] data) { Packet response = SendAndReceive(Packet.Create(APCommand.BM_SYNC_READ_BUFFER, null), Constants.BM_SYNC_DATA_LEN, 0); data = new byte[Constants.BM_SYNC_DATA_LEN]; for (int i = 0; i < Constants.BM_SYNC_DATA_LEN; i++) { data[i] = response.Data[Constants.PACKET_DATA_START + i]; } return(CheckResponse(response)); }
/// <summary> /// Get RF access point dummy ID - used by live check /// </summary> /// <param name="ID">ID of the connected access point</param> /// <returns></returns> public bool GetID(out UInt32 ID) { byte[] data = new byte[4] { 0x00, 0x00, 0x00, 0x00 }; Packet response = SendAndReceive(Packet.Create(APCommand.BM_GET_PRODUCT_ID, data), data.Length, 1); ID = (uint)(response.Data[Constants.PACKET_DATA_START + 3] << 24) + (uint)(response.Data[Constants.PACKET_DATA_START + 2] << 16) + (uint)(response.Data[Constants.PACKET_DATA_START + 1] << 8) + (response.Data[Constants.PACKET_DATA_START]); return(CheckResponse(response)); }
/// <summary> /// Get SimpliciTI acc/ppt data (4 bytes) /// </summary> /// <returns></returns> public bool GetData(out UInt32 data) { byte[] send = new byte[4] { 0x00, 0x00, 0x00, 0x00 }; Packet response = SendAndReceive(Packet.Create(APCommand.BM_GET_SIMPLICITIDATA, send), send.Length, 1); data = (uint)(response.Data[Constants.PACKET_DATA_START + 3] << 24) + (uint)(response.Data[Constants.PACKET_DATA_START + 2] << 16) + (uint)(response.Data[Constants.PACKET_DATA_START + 1] << 8) + (response.Data[Constants.PACKET_DATA_START]); return(CheckResponse(response)); }
/* SimpliciTI sync mode methods **********************************************************************************/ /// <summary> /// Start RF access point sync mode /// </summary> /// <returns></returns> public bool StartSyncMode() { Packet response = SendAndReceive(Packet.Create(APCommand.BM_SYNC_START, null), 0, 1); return(CheckResponse(response)); }
/// <summary> /// Stop SimpliciTI stack /// </summary> /// <returns></returns> public bool StopSimpiliTI() { Packet response = SendAndReceive(Packet.Create(APCommand.BM_STOP_SIMPLICITI, null), 0, 1); return(CheckResponse(response)); }