Example #1
0
// The decode function
func decode(data []byte, uuid string) []interface{} {

	var bytesRemaining C.uint32_t = 1
	var returnedMsgs []interface{} = nil
	var used C.uint32_t

	// Holder for the extracted message
	pBuffer := (*C.UlMsgUnion_t)(unsafe.Pointer(&inputBuffer))

	// Loop over the messages in the datagram
	pStart := (*C.char)(unsafe.Pointer(&data[0]))
	pNext := pStart
	ppNext := (**C.char)(unsafe.Pointer(&pNext))

	hexBuffer := hex.Dump(data)
	globals.Dbg.PrintfInfo("%s [decode] --> the whole input buffer:\n\n%s\n\n", globals.LogTag, hexBuffer)

	var decoderCount uint32

	for bytesRemaining > 0 {
		decoderCount = decoderCount + 1

		globals.Dbg.PrintfTrace("%s [decode] --> decoding message number %d of AMQP message number %d.\n", globals.LogTag, decoderCount, amqpMessageCount)

		globals.Dbg.PrintfInfo("%s -----## show buffer data ##-----\n\n%s\n\n", globals.LogTag, spew.Sdump(inputBuffer))
		used = C.pointerSub(pNext, pStart)
		globals.Dbg.PrintfInfo("%s [decode] --> message data used: %d.\n", globals.LogTag, used)
		bytesRemaining = C.uint32_t(len(data)) - used
		globals.Dbg.PrintfInfo("%s [decode] --> %d bytes remaining out of %d.\n", globals.LogTag, bytesRemaining, len(data))
		if bytesRemaining > 0 {
			// A place to put the XML output from the decoder
			pXmlBuffer := (*C.char)(unsafe.Pointer(&(xmlDecodeBuffer[0])))
			ppXmlBuffer := (**C.char)(unsafe.Pointer(&pXmlBuffer))
			xmlBufferLen := (C.uint32_t)(len(xmlDecodeBuffer))
			pXmlBufferLen := (*C.uint32_t)(unsafe.Pointer(&xmlBufferLen))

			result := C.decodeUlMsg(ppNext, bytesRemaining, pBuffer, ppXmlBuffer, pXmlBufferLen)
			globals.Dbg.PrintfTrace("%s [decode] --> decode received uplink message: %+v.\n\n-----## %s ##----- \n\n", globals.LogTag, result, ulDecodeTypeDisplay[int(result)])
			globals.Dbg.PrintfInfo("%s [decode] --> XML buffer pointer 0x%08x, used %d, left %d:.\n", globals.LogTag, *ppXmlBuffer, C.uint32_t(len(xmlDecodeBuffer))-xmlBufferLen, xmlBufferLen)

			//Store XmlData in MongoDB
			//XmlDataStore(xmlDecodeBuffer, uuid)
			//Dbg.PrintfInfo("%s [decode] -->  the XML data is:\n\n%s\n\n", logTag, spew.Sdump(xmlDecodeBuffer))

			// Now decode the messages and pass them to the state table
			switch int(result) {
			case C.DECODE_RESULT_TRANSPARENT_UL_DATAGRAM:
				// TODO
			case C.DECODE_RESULT_PING_REQ_UL_MSG:
				// Empty message
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message:    &PingReqUlMsg{},
					})
			case C.DECODE_RESULT_PING_CNF_UL_MSG:
				// Empty message
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message:    &PingCnfUlMsg{},
					})
			case C.DECODE_RESULT_INIT_IND_UL_MSG:
				value := C.getInitIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &InitIndUlMsg{
							WakeUpCode:        WakeUpEnum(value.wakeUpCode),
							RevisionLevel:     uint8(value.revisionLevel),
							SdCardNotRequired: bool(value.sdCardNotRequired),
							DisableModemDebug: bool(value.disableModemDebug),
							DisableButton:     bool(value.disableButton),
							DisableServerPing: bool(value.disableServerPing),
						},
					})

			case C.DECODE_RESULT_DATE_TIME_IND_UL_MSG:
				value := C.getDateTimeIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &DateTimeIndUlMsg{
							UtmTime:   time.Unix(int64(value.time), 0).Local(),
							TimeSetBy: TimeSetByEnum(value.setBy),
						},
					})

			case C.DECODE_RESULT_DATE_TIME_SET_CNF_UL_MSG:
				value := C.getDateTimeSetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &DateTimeSetCnfUlMsg{
							UtmTime:   time.Unix(int64(value.time), 0).Local(),
							TimeSetBy: TimeSetByEnum(value.setBy),
						},
					})

			case C.DECODE_RESULT_DATE_TIME_GET_CNF_UL_MSG:
				value := C.getDateTimeGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &DateTimeGetCnfUlMsg{
							UtmTime:   time.Unix(int64(value.time), 0).Local(),
							TimeSetBy: TimeSetByEnum(value.setBy),
						},
					})

			case C.DECODE_RESULT_MODE_SET_CNF_UL_MSG:
				value := C.getModeSetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &ModeSetCnfUlMsg{
							Mode: ModeEnum(value.mode),
						},
					})

			case C.DECODE_RESULT_MODE_GET_CNF_UL_MSG:
				value := C.getModeGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &ModeGetCnfUlMsg{
							Mode: ModeEnum(value.mode),
						},
					})

			case C.DECODE_RESULT_HEARTBEAT_SET_CNF_UL_MSG:
				value := C.getHeartbeatSetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &HeartbeatSetCnfUlMsg{
							HeartbeatSeconds:   uint32(value.heartbeatSeconds),
							HeartbeatSnapToRtc: bool(value.heartbeatSnapToRtc),
						},
					})

			case C.DECODE_RESULT_REPORTING_INTERVAL_SET_CNF_UL_MSG:
				value := C.getReportingIntervalSetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &ReportingIntervalSetCnfUlMsg{
							ReportingInterval: uint32(value.reportingInterval),
						},
					})

			case C.DECODE_RESULT_INTERVALS_GET_CNF_UL_MSG:
				value := C.getIntervalsGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &IntervalsGetCnfUlMsg{
							ReportingInterval:  uint32(value.reportingInterval),
							HeartbeatSeconds:   uint32(value.heartbeatSeconds),
							HeartbeatSnapToRtc: bool(value.heartbeatSnapToRtc),
						},
					})

			case C.DECODE_RESULT_POLL_IND_UL_MSG:
				value := C.getPollIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &PollIndUlMsg{
							Mode:          ModeEnum(value.mode),
							EnergyLeft:    EnergyLeftEnum(value.energyLeft),
							DiskSpaceLeft: DiskSpaceLeftEnum(value.diskSpaceLeft),
						},
					})

			case C.DECODE_RESULT_MEASUREMENTS_IND_UL_MSG:
				value := C.getMeasurementsIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &MeasurementsIndUlMsg{ // Structure initialisation is just horrible in this language
							Measurements: MeasurementData{
								TimeMeasured:        time.Unix(int64(value.measurements.time), 0).Local(),
								GnssPositionPresent: bool(value.measurements.gnssPositionPresent),
								GnssPosition: GnssPosition{
									Latitude:  int32(value.measurements.gnssPosition.latitude),
									Longitude: int32(value.measurements.gnssPosition.longitude),
									Elevation: int32(value.measurements.gnssPosition.elevation),
								},
								CellIdPresent: bool(value.measurements.cellIdPresent),
								CellId:        CellId(value.measurements.cellId),
								RsrpPresent:   bool(value.measurements.rsrpPresent),
								Rsrp: Rsrp{
									Value:            Rssi(value.measurements.rsrp.value),
									IsSyncedWithRssi: bool(value.measurements.rsrp.isSyncedWithRssi),
								},
								RssiPresent:        bool(value.measurements.rssiPresent),
								Rssi:               Rssi(value.measurements.rssi),
								TemperaturePresent: bool(value.measurements.temperaturePresent),
								Temperature:        Temperature(value.measurements.temperature),
								PowerStatePresent:  bool(value.measurements.powerStatePresent),
								PowerState: PowerState{
									ChargerState: ChargerStateEnum(value.measurements.powerState.chargerState),
									BatteryMv:    uint16(value.measurements.powerState.batteryMV),
									EnergyMwh:    uint32(value.measurements.powerState.energyMWh),
								},
							},
						},
					})

			case C.DECODE_RESULT_MEASUREMENTS_GET_CNF_UL_MSG:
				value := C.getMeasurementsGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &MeasurementsIndUlMsg{ // Still horrible
							Measurements: MeasurementData{
								TimeMeasured:        time.Unix(int64(value.measurements.time), 0).Local(),
								GnssPositionPresent: bool(value.measurements.gnssPositionPresent),
								GnssPosition: GnssPosition{
									Latitude:  int32(value.measurements.gnssPosition.latitude),
									Longitude: int32(value.measurements.gnssPosition.longitude),
									Elevation: int32(value.measurements.gnssPosition.elevation),
								},
								CellIdPresent: bool(value.measurements.cellIdPresent),
								CellId:        CellId(value.measurements.cellId),
								RsrpPresent:   bool(value.measurements.rsrpPresent),
								Rsrp: Rsrp{
									Value:            Rssi(value.measurements.rsrp.value),
									IsSyncedWithRssi: bool(value.measurements.rsrp.isSyncedWithRssi),
								},
								RssiPresent:        bool(value.measurements.rssiPresent),
								Rssi:               Rssi(value.measurements.rssi),
								TemperaturePresent: bool(value.measurements.temperaturePresent),
								Temperature:        Temperature(value.measurements.temperature),
								PowerStatePresent:  bool(value.measurements.powerStatePresent),
								PowerState: PowerState{
									ChargerState: ChargerStateEnum(value.measurements.powerState.chargerState),
									BatteryMv:    uint16(value.measurements.powerState.batteryMV),
									EnergyMwh:    uint32(value.measurements.powerState.energyMWh),
								},
							},
						},
					})

			case C.DECODE_RESULT_MEASUREMENTS_CONTROL_IND_UL_MSG:
			// TODO
			case C.DECODE_RESULT_MEASUREMENT_CONTROL_SET_CNF_UL_MSG:
			// TODO
			case C.DECODE_RESULT_MEASUREMENTS_CONTROL_GET_CNF_UL_MSG:
			// TODO
			case C.DECODE_RESULT_MEASUREMENTS_CONTROL_DEFAULTS_SET_CNF_UL_MSG:
			// TODO
			case C.DECODE_RESULT_TRAFFIC_REPORT_IND_UL_MSG:
				value := C.getTrafficReportIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &TrafficReportIndUlMsg{
							NumDatagramsUl:            uint32(value.numDatagramsUl),
							NumBytesUl:                uint32(value.numBytesUl),
							NumDatagramsDl:            uint32(value.numDatagramsDl),
							NumBytesDl:                uint32(value.numBytesDl),
							NumDatagramsDlBadChecksum: uint32(value.numDatagramsDlBadChecksum),
						},
					})

			case C.DECODE_RESULT_TRAFFIC_REPORT_GET_CNF_UL_MSG:
				value := C.getTrafficReportGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &TrafficReportGetCnfUlMsg{
							NumDatagramsUl:            uint32(value.numDatagramsUl),
							NumBytesUl:                uint32(value.numBytesUl),
							NumDatagramsDl:            uint32(value.numDatagramsDl),
							NumBytesDl:                uint32(value.numBytesDl),
							NumDatagramsDlBadChecksum: uint32(value.numDatagramsDlBadChecksum),
						},
					})

			case C.DECODE_RESULT_TRAFFIC_TEST_MODE_PARAMETERS_SET_CNF_UL_MSG:
				value := C.getTrafficTestModeParametersSetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &TrafficTestModeParametersSetCnfUlMsg{
							NumUlDatagrams: uint32(value.numUlDatagrams),
							LenUlDatagram:  uint32(value.lenUlDatagram),
							NumDlDatagrams: uint32(value.numDlDatagrams),
							LenDlDatagram:  uint32(value.lenDlDatagram),
						},
					})

			case C.DECODE_RESULT_TRAFFIC_TEST_MODE_PARAMETERS_GET_CNF_UL_MSG:
				value := C.getTrafficTestModeParametersGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &TrafficTestModeParametersGetCnfUlMsg{
							NumUlDatagrams: uint32(value.numUlDatagrams),
							LenUlDatagram:  uint32(value.lenUlDatagram),
							NumDlDatagrams: uint32(value.numDlDatagrams),
							LenDlDatagram:  uint32(value.lenDlDatagram),
						},
					})

			case C.DECODE_RESULT_TRAFFIC_TEST_MODE_RULE_BREAKER_UL_DATAGRAM:
			// TODO

			case C.DECODE_RESULT_TRAFFIC_TEST_MODE_REPORT_IND_UL_MSG:
				value := C.getTrafficTestModeReportIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &TrafficTestModeReportIndUlMsg{
							NumTrafficTestDatagramsUl:           uint32(value.numTrafficTestDatagramsUl),
							NumTrafficTestBytesUl:               uint32(value.numTrafficTestBytesUl),
							NumTrafficTestDatagramsDl:           uint32(value.numTrafficTestDatagramsDl),
							NumTrafficTestBytesDl:               uint32(value.numTrafficTestBytesDl),
							NumTrafficTestDlDatagramsOutOfOrder: uint32(value.numTrafficTestDlDatagramsOutOfOrder),
							NumTrafficTestDlDatagramsBad:        uint32(value.numTrafficTestDlDatagramsBad),
							NumTrafficTestDlDatagramsMissed:     uint32(value.numTrafficTestDlDatagramsMissed),
							TimedOut:                            bool(value.timedOut),
						},
					})

			case C.DECODE_RESULT_TRAFFIC_TEST_MODE_REPORT_GET_CNF_UL_MSG:
				value := C.getTrafficTestModeReportGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &TrafficTestModeReportGetCnfUlMsg{
							NumTrafficTestDatagramsUl:           uint32(value.numTrafficTestDatagramsUl),
							NumTrafficTestBytesUl:               uint32(value.numTrafficTestBytesUl),
							NumTrafficTestDatagramsDl:           uint32(value.numTrafficTestDatagramsDl),
							NumTrafficTestBytesDl:               uint32(value.numTrafficTestBytesDl),
							NumTrafficTestDlDatagramsOutOfOrder: uint32(value.numTrafficTestDlDatagramsOutOfOrder),
							NumTrafficTestDlDatagramsBad:        uint32(value.numTrafficTestDlDatagramsBad),
							NumTrafficTestDlDatagramsMissed:     uint32(value.numTrafficTestDlDatagramsMissed),
							TimedOut:                            bool(value.timedOut),
						},
					})

			case C.DECODE_RESULT_ACTIVITY_REPORT_IND_UL_MSG:
				value := C.getActivityReportIndUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &ActivityReportIndUlMsg{
							TotalTransmitMilliseconds: uint32(value.totalTransmitMilliseconds),
							TotalReceiveMilliseconds:  uint32(value.totalReceiveMilliseconds),
							UpTimeSeconds:             uint32(value.upTimeSeconds),
							TxPowerDbmPresent:         bool(value.txPowerDbmPresent),
							TxPowerDbm:                int8(value.txPowerDbm),
							UlMcsPresent:              bool(value.ulMcsPresent),
							UlMcs:                     uint8(value.ulMcs),
							DlMcsPresent:              bool(value.dlMcsPresent),
							DlMcs:                     uint8(value.dlMcs),
						},
					})

			case C.DECODE_RESULT_ACTIVITY_REPORT_GET_CNF_UL_MSG:
				value := C.getActivityReportGetCnfUlMsg(inputBuffer)
				returnedMsgs = append(returnedMsgs,
					&MessageContainer{
						DeviceUuid: uuid,
						Timestamp:  time.Now(),
						Message: &ActivityReportGetCnfUlMsg{
							TotalTransmitMilliseconds: uint32(value.totalTransmitMilliseconds),
							TotalReceiveMilliseconds:  uint32(value.totalReceiveMilliseconds),
							UpTimeSeconds:             uint32(value.upTimeSeconds),
							TxPowerDbmPresent:         bool(value.txPowerDbmPresent),
							TxPowerDbm:                int8(value.txPowerDbm),
							UlMcsPresent:              bool(value.ulMcsPresent),
							UlMcs:                     uint8(value.ulMcs),
							DlMcsPresent:              bool(value.dlMcsPresent),
							DlMcs:                     uint8(value.dlMcs),
						},
					})

			case C.DECODE_RESULT_DEBUG_IND_UL_MSG:
			// TODO
			case C.DECODE_RESULT_FAILURE:
			case C.DECODE_RESULT_INPUT_TOO_SHORT:
			case C.DECODE_RESULT_OUTPUT_TOO_SHORT:
			case C.DECODE_RESULT_UNKNOWN_MSG_ID:
			case C.DECODE_RESULT_BAD_MSG_FORMAT:
			case C.DECODE_RESULT_BAD_TRAFFIC_TEST_MODE_DATAGRAM:
			// TODO
			case C.DECODE_RESULT_OUT_OF_SEQUENCE_TRAFFIC_TEST_MODE_DATAGRAM:
			// TODO
			case C.DECODE_RESULT_BAD_CHECKSUM:
			default:
				// Can't decode the message, throw it away silently
			}
		}
	}

	totalUlMsgs += len(returnedMsgs)
	totalUlBytes += int(used)
	lastUlMsgTime = time.Now()

	return returnedMsgs
}
Example #2
0
func decode(data []byte) {

	var xmlBuffer [8192]C.char
	// A place to put the XML output from the decoder
	// pXmlBuffer := (*C.char)(unsafe.Pointer(&(xmlBuffer[0])))
	// ppXmlBuffer := (**C.char)(unsafe.Pointer(&pXmlBuffer))

	// xmlBufferLen := (C.uint32_t)(len(xmlBuffer))
	// pXmlBufferLen := (*C.uint32_t)(unsafe.Pointer(&xmlBufferLen))

	// Holder for the extracted message
	var inputBuffer C.union_UlMsgUnionTag_t
	inputPointer := (*C.UlMsgUnion_t)(unsafe.Pointer(&inputBuffer))
	//Row.TotalMsgs = Row.TotalMsgs + uint64(len(data))
	Row.UTotalMsgs = Row.UTotalMsgs + uint64(len(data))

	// Loop over the messages in the datagram
	startPointer := (*C.char)(unsafe.Pointer(&data[0]))
	nextPointer := (*C.char)(unsafe.Pointer(&data[0]))
	nextPointerPointer := (**C.char)(unsafe.Pointer(&nextPointer))

	hexBuffer := hex.Dump(data)
	fmt.Printf("\n\n===>The Whole Input Butter (%s) \n", hexBuffer)

	var decoderCount int

	for {
		decoderCount = decoderCount + 1
		//TotalMsgs = TotalMsgs + 1
		now := time.Now()
		Row.LastMsgReceived = &now

		fmt.Printf("\n\n===>DECODING MESSAGE NO (%v)  OF AMQP DATAGRAM NO (%v) \n", decoderCount, amqpCount)

		fmt.Printf("\n%s -----## SHOW BUFFER DATA ##----- \n\n %s\n\n", logTag, spew.Sdump(inputBuffer))
		used := C.pointerSub(nextPointer, startPointer)
		fmt.Printf("%s MESSAGE DATA USED %s\n", logTag, spew.Sdump(used))
		remaining := C.uint32_t(len(data)) - used
		fmt.Printf("%s MESSAGE DATA REMAINING %s\n", logTag, spew.Sdump(remaining))
		if remaining == 0 {
			break
		}

		//result := C.decodeUlMsg(nextPointerPointer, remaining, inputPointer, ppXmlBuffer, pXmlBufferLen)
		result := C.decodeUlMsg(nextPointerPointer, remaining, inputPointer, nil, nil)

		//Store XmlData in MongoDB
		XmlDataStore(xmlBuffer)

		fmt.Printf("\n%s -----+++ THE XML DATA IS ++----- \n\n %s\n\n", logTag, spew.Sdump(xmlBuffer))

		fmt.Printf("%s DECODE RECEIVED UPLINK MESSAGE %+v \n\n -----## %s ##----- \n\n", logTag, result, ulDecodeTypeDisplay[int(result)])

		// Extract any data to be recorded; the C symbols are not available outside
		// the package so convert into concrete go types
		var data interface{} = nil
		var rawData interface{} = nil
		var multipleRecords []interface{} = nil

		switch int(result) {
		case C.DECODE_RESULT_INIT_IND_UL_MSG:
			value := C.getInitIndUlMsg(inputBuffer)
			rawData = value
			data = &InitIndUlMsg{
				Timestamp:         time.Now(),
				WakeUpCode:        WakeUpEnum(value.wakeUpCode),
				RevisionLevel:     uint16(value.revisionLevel),
				sdCardNotRequired: bool(value.sdCardNotRequired),
			}

		case C.DECODE_RESULT_INTERVALS_GET_CNF_UL_MSG:
			value := C.getIntervalsGetCnfUlMsg(inputBuffer)
			rawData = value
			data = &IntervalsGetCnfUlMsg{
				ReportingInterval:  uint32(value.reportingInterval),
				HeartbeatSeconds:   uint32(value.heartbeatSeconds),
				HeartbeatSnapToRtc: bool(value.heartbeatSnapToRtc),
			}

			Row.ReportingInterval = uint32(value.reportingInterval)
			Row.HeartbeatSeconds = uint32(value.heartbeatSeconds)
			Row.HeartbeatSnapToRtc = bool(value.heartbeatSnapToRtc)
			multipleRecords = append(multipleRecords, Row)

			fmt.Printf("%s RECEIVED INTERVAL REQUEST CONFIRM %s\n", logTag, spew.Sdump(Row))

		case C.DECODE_RESULT_REPORTING_INTERVAL_SET_CNF_UL_MSG:
			value := C.getReportingIntervalSetCnfUlMsg(inputBuffer)
			rawData = value
			data = &ReportingIntervalSetCnfUlMsg{
				Timestamp: time.Now(),
				//ReportingIntervalMinutes: uint32(value.reportingInterval),
			}

		case C.DECODE_RESULT_HEARTBEAT_SET_CNF_UL_MSG:
			rawData = C.getHeartbeatSetCnfUlMsg(inputBuffer)

		case C.DECODE_RESULT_POLL_IND_UL_MSG:
			value := C.getPollIndUlMsg(inputBuffer)
			rawData = value
			data = &PollIndUlMsg{
				Mode:          string(ModeEnum(value.mode)),
				EnergyLeft:    string(EnergyLeftEnum(value.energyLeft)),
				DiskSpaceLeft: string(DiskSpaceLeft(value.diskSpaceLeft)),
			}

			//Row.UTotalMsgs = TotalMsgs
			Row.Mode = ModeLookUp[string(ModeEnum(value.mode))]
			Row.BatteryLevel = EnergyLeftLookUP[int(EnergyLeftEnum(value.energyLeft))]
			Row.DiskSpaceLeft = DiskSpaceLookUP[int(DiskSpaceLeft(value.diskSpaceLeft))]

			multipleRecords = append(multipleRecords, Row)

			//encodeAndEnqueueIntervalGetReq(Row.Uuid)

		case C.DECODE_RESULT_DEBUG_IND_UL_MSG:
			rawData = C.getDebugIndUlMsg(inputBuffer)

		case C.DECODE_RESULT_TRAFFIC_REPORT_GET_CNF_UL_MSG:
			rawData = C.getTrafficReportGetCnfUlMsg(inputBuffer)

		case C.DECODE_RESULT_TRAFFIC_REPORT_IND_UL_MSG:
			value := C.getTrafficReportIndUlMsg(inputBuffer)
			rawData = value
			data = &TrafficReportIndUlMsg{
				numDatagramsUl: int32(value.numDatagramsUl),
				numBytesUl:     int32(value.numBytesUl),
				numDatagramsDl: int32(value.numDatagramsDl),
				numBytesDl:     int32(value.numBytesDl),
			}

		case C.DECODE_RESULT_TRANSPARENT_UL_DATAGRAM:
			rawData = "value"
			//encodeAndEnqueueIntervalGetReq(Row.Uuid)
		case C.DECODE_RESULT_DATE_TIME_IND_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_DATE_TIME_SET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_DATE_TIME_GET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MODE_SET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MODE_GET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MEASUREMENTS_GET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MEASUREMENTS_IND_UL_MSG:
			value := C.getMeasurementsIndUlMsg(inputBuffer)
			rawData = value
			Row.RSRP = int32(value.measurements.rsrp.value) / 10
		case C.DECODE_RESULT_MEASUREMENT_CONTROL_SET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MEASUREMENTS_CONTROL_GET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MEASUREMENTS_CONTROL_IND_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_MEASUREMENTS_CONTROL_DEFAULTS_SET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_TRAFFIC_TEST_MODE_PARAMETERS_SET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_TRAFFIC_TEST_MODE_PARAMETERS_GET_CNF_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_TRAFFIC_TEST_MODE_RULE_BREAKER_UL_DATAGRAM:
			rawData = "value"
		case C.DECODE_RESULT_TRAFFIC_TEST_MODE_REPORT_IND_UL_MSG:
			rawData = "value"
		case C.DECODE_RESULT_TRAFFIC_TEST_MODE_REPORT_GET_CNF_UL_MSG:
			rawData = "value"

		default:
			// Can't decode the uplink; this case is here to avoid a panic,
			// the code below will handle this situation fine
		}

		// Send any data to be recorded
		if multipleRecords != nil {
			// Iterate once to get a description of the objects to be recorded and display it
			txt := ""
			for _, record := range multipleRecords {
				txt = fmt.Sprintf("%s%+v ", txt, record)
			}
			fmt.Printf("%s MULTIPLE DECODED ENTRIES BEING RECORDED = %s\n", logTag, txt)
			// Then record the objects
			for _, record := range multipleRecords {
				StateTableCmds <- record
			}
		} else if data != nil {
			fmt.Printf("%s DECODED DATA BEING RECORDED = %+v\n", logTag, data)
			StateTableCmds <- data
		} else if rawData != nil {
			fmt.Printf("%s DATA NOT BEING RECORDED = %+v\n", logTag, rawData)
		} else {
			fmt.Printf("%s ERROR: UNDECODABLE MESSGE RECEIVED %s\n", logTag, spew.Sdump(inputBuffer))

			//if you get here, break from this loop;
			break
		}

	}

	decoderCount = 0
}