public static int ParseParams(LogicChannel channelData, int offset, Rules[] rules, ReceivedData result) { var skipRules = 0; for (int i = 0; i < rules.Length; i++) { if (offset >= channelData.Length) { if (!result.Contains(GlobalNames.OutOfBuffer)) { result.SetValue(GlobalNames.OutOfBuffer, 1); } return(offset); } if (skipRules > 0) { skipRules--; continue; } var param = rules[i]; var value = TetraUtils.BitsToInt32(channelData.Ptr, offset, param.Length); switch (param.Type) { case RulesType.Direct: if (param.GlobalName != GlobalNames.Reserved) { result.SetValue(param.GlobalName, value); } offset += param.Length; continue; case RulesType.Options_bit: offset += param.Length; if (value == 0) { return(offset); } break; case RulesType.Presence_bit: if (value == 0) { skipRules = param.Ext1; } offset += param.Length; break; case RulesType.More_bit: offset += param.Length; return(offset); case RulesType.Switch: if (result.Value((GlobalNames)rules[i].Ext1) == rules[i].Ext2) { if (param.GlobalName != GlobalNames.Reserved) { result.SetValue(param.GlobalName, value); } offset += param.Length; } break; case RulesType.SwitchNot: if (result.Value((GlobalNames)rules[i].Ext1) != rules[i].Ext2) { if (param.GlobalName != GlobalNames.Reserved) { result.SetValue(param.GlobalName, value); } offset += param.Length; } break; case RulesType.Jamp: if (result.Value((GlobalNames)rules[i].Ext1) == rules[i].Ext2) { skipRules = param.Ext3; } break; case RulesType.JampNot: if (result.Value((GlobalNames)rules[i].Ext1) != rules[i].Ext2) { skipRules = param.Ext3; } break; case RulesType.Reserved: { offset += param.Length; } break; } } return(offset); }
public void Parse(LogicChannel channelData, int offset, ReceivedData result) { var llcType = (LLCPduType)TetraUtils.BitsToInt32(channelData.Ptr, offset, 4); offset += 4; result.Add(GlobalNames.LLC_Pdu_Type, (int)llcType); //Debug.WriteLine(" " + llcType.ToString()); var fcsIsGood = true; switch (llcType) { case LLCPduType.BL_ADATA: offset += 1; //N(R) offset += 1; //N(S) break; case LLCPduType.BL_ADATA_FCS: offset += 1; //N(R) offset += 1; //N(S) fcsIsGood = CalculateFCS(channelData, offset); break; case LLCPduType.BL_DATA: offset += 1; //N(S) break; case LLCPduType.BL_DATA_FCS: offset += 1; //N(S) fcsIsGood = CalculateFCS(channelData, offset); break; case LLCPduType.BL_UDATA: //No bits here break; case LLCPduType.BL_UDATA_FCS: //No bits here fcsIsGood = CalculateFCS(channelData, offset); break; case LLCPduType.BL_ACK: offset += 1; //N(R) break; case LLCPduType.BL_ACK_FCS: offset += 1; //N(R) fcsIsGood = CalculateFCS(channelData, offset); break; case LLCPduType.AL_SETUP: case LLCPduType.AL_DATA_AR_FINAL: case LLCPduType.AL_UDATA_UFINAL: case LLCPduType.AL_ACK_RNR: case LLCPduType.AL_RECONNECT: case LLCPduType.Reserved1: case LLCPduType.Reserved2: case LLCPduType.AL_DISC: default: Debug.WriteLine(" Unknow_LLC_PDU " + llcType); result.Add(GlobalNames.UnknowData, 1); return; } if (fcsIsGood) { _mle.Parse(channelData, offset, result); } else { result.Add(GlobalNames.UnknowData, 1); } }
private unsafe void ParseLongSDS(LogicChannel channelData, int offset, ReceivedData result) { throw new NotImplementedException(); }
private unsafe void ParseTextMessage(LogicChannel channelData, int offset, ReceivedData result) { if (result.Contains(GlobalNames.OutOfBuffer)) { return; } var codingSheme = result.Value(GlobalNames.Text_coding_scheme); Encoding encTable = Encoding.GetEncoding("iso-8859-1"); int symbLength = 8; switch (codingSheme) { case 1: encTable = Encoding.GetEncoding("iso-8859-1"); break; case 2: encTable = Encoding.GetEncoding("iso-8859-2"); break; case 3: encTable = Encoding.GetEncoding("iso-8859-3"); break; case 4: encTable = Encoding.GetEncoding("iso-8859-4"); break; case 5: encTable = Encoding.GetEncoding("iso-8859-5"); break; case 6: encTable = Encoding.GetEncoding("iso-8859-6"); break; case 7: encTable = Encoding.GetEncoding("iso-8859-7"); break; case 8: encTable = Encoding.GetEncoding("iso-8859-8"); break; case 9: encTable = Encoding.GetEncoding("iso-8859-9"); break; case 10: encTable = Encoding.GetEncoding("iso-8859-10"); break; case 11: encTable = Encoding.GetEncoding("iso-8859-13"); break; case 12: encTable = Encoding.GetEncoding("iso-8859-14"); break; case 13: encTable = Encoding.GetEncoding("iso-8859-15"); break; case 14: encTable = Encoding.GetEncoding(437); break; case 15: encTable = Encoding.GetEncoding(737); break; case 16: encTable = Encoding.GetEncoding(850); break; case 17: encTable = Encoding.GetEncoding(852); break; case 18: encTable = Encoding.GetEncoding(855); break; case 19: encTable = Encoding.GetEncoding(857); break; case 20: encTable = Encoding.GetEncoding(860); break; case 21: encTable = Encoding.GetEncoding(861); break; case 22: encTable = Encoding.GetEncoding(863); break; case 23: encTable = Encoding.GetEncoding(865); break; case 24: encTable = Encoding.GetEncoding(866); break; case 25: encTable = Encoding.GetEncoding(869); break; default: break; result.Add(GlobalNames.UnknowData, 1); return; } Decoder dec = encTable.GetDecoder(); var messageLength = (channelData.Length - offset) / symbLength; if (messageLength < 0) { return; } string message; byte[] symbolsArray = new byte[messageLength]; int index = 0; while (messageLength > 0) { symbolsArray[index++] = TetraUtils.BitsToByte(channelData.Ptr, offset, symbLength); offset += symbLength; messageLength--; } message = encTable.GetString(symbolsArray); Debug.WriteLine(" data:" + message); }
private void ParseLocationInformationProtokol(LogicChannel channelData, int offset, ReceivedData result) { var length = 2; var pduType = TetraUtils.BitsToInt32(channelData.Ptr, offset, length); offset += length; result.Add(GlobalNames.Location_PDU_type, pduType); switch (pduType) { case 0: //Short Global.ParseParams(channelData, offset, _sds_LocationShortRules, result); break; case 1: //Long length = 4; var pduSubType = (LocationTypeExtension)TetraUtils.BitsToInt32(channelData.Ptr, offset, length); offset += length; result.Add(GlobalNames.Location_PDU_type_extension, (int)pduSubType); switch (pduSubType) { case LocationTypeExtension.Immediate_location_report: Global.ParseParams(channelData, offset, _sds_ImmediateLocRepRules, result); break; case LocationTypeExtension.Long_location_report: case LocationTypeExtension.Remove_trigger: case LocationTypeExtension.Location_report_acknowledgement: case LocationTypeExtension.Add_modify_trigger: case LocationTypeExtension.Backlog: case LocationTypeExtension.Basic_location_parameters: case LocationTypeExtension.Location_reporting_enable_disable: case LocationTypeExtension.Location_reporting_temporary_control: case LocationTypeExtension.Report_basic_location_parameters: case LocationTypeExtension.Report_trigger: default: result.Add(GlobalNames.UnknowData, 1); break; } break; default: break; } }
private void CreateFraqmentsBuffer(LogicChannel buffer, int offset, int length, ReceivedData header) { var ts = buffer.TimeSlot - 1; Debug.WriteIf(_writeAddress[ts] != 0, " Warning!!! Fraqments buffer is not empty!"); if (_writeAddress[ts] + length < _tempBuffers[ts].Length) { Radio.Utils.Memcpy(_tempBuffersPtr[ts], buffer.Ptr + offset, length * sizeof(byte)); _writeAddress[ts] = length; if (header != null) { for (int i = 0; i < header.Data.Length; i++) { _fragmentsHeader[ts].Data[i] = header.Data[i]; } } } }
public void TmoParseMacPDU(LogicChannel channelData, List <ReceivedData> result) { var nullPduLength = 16; // only for receive pi/4 modulation ; var blockOffset = 0; var nullPdu = false; var pduEnd = false; for (int i = 0; i < 5; i++) { var offset = blockOffset; var pdu = new ReceivedData(); pdu.Add(GlobalNames.CurrTimeSlot, channelData.TimeSlot); var resourceType = (MAC_PDU_Type)TetraUtils.BitsToInt32(channelData.Ptr, offset, 2); offset += 2; pdu.Add(GlobalNames.MAC_PDU_Type, (int)resourceType); switch (resourceType) { case MAC_PDU_Type.Broadcast: blockOffset = SysInfoPDU(channelData, offset, pdu); break; case MAC_PDU_Type.MAC_resource: ResourcePDU(channelData, offset, pdu); blockOffset += (pdu.Value(GlobalNames.Length_indication) * 8); break; case MAC_PDU_Type.MAC_U_Signal: if (channelData.Length == 124) { UsignalPDU(channelData, offset, pdu); pduEnd = true; } else { Debug.Write(" MAC-D-BLCK_PDU"); pduEnd = true; } break; case MAC_PDU_Type.MAC_frag: var isTheEnd = TetraUtils.BitsToInt32(channelData.Ptr, offset, 1); offset++; if (isTheEnd == 0) { MacFraqPDU(channelData, offset, pdu); pduEnd = true; } else { MacEndPDU(channelData, offset, pdu); blockOffset += (pdu.Value(GlobalNames.Length_indication) * 8); } break; } nullPdu = pdu.Contains(GlobalNames.Null_pdu) || pdu.Contains(GlobalNames.OutOfBuffer); if (nullPdu) { pduEnd = true; } //if (pdu.ContainsKey(GlobalNames.UnknowData)) nullPdu = true; if (!nullPdu) { result.Add(pdu); } if ((blockOffset >= (channelData.Length - nullPduLength)) || pduEnd) { break; } } }