// 监控对象
// 秒寻科技
// zt 2024-09-17

package oam

import (
	"encoding/binary"
	"ipsomc/module/bparam/bparammodel"
	"ipsomc/util"
)

type OamDevice struct {
}

const (
	ORDER_DEVICE_TYPE          = 0x0001 // 设备类型
	ORDER_DEVICE_SERIAL_NO     = 0x0002 // 设备序列号
	ORDER_DEVICE_MODEL         = 0x0003 // 设备型号
	ORDER_DEVICE_MCU_VERSION   = 0x0004 // 软件版本
	ORDER_DEVICE_PROJECT_ID    = 0x0005 // 网管协议版本号
	ORDER_DEVICE_BLE_BTS_NAME  = 0x0006 // 蓝牙基站名称
	ORDER_DEVICE_WIFI_BTS_NAME = 0x0007 // wifi基站名称
)

// 设备参数查询响应
// dataModel:基站基本参数模型
// wCommand:监控命令
// datalist:数据队列
// wLen:队列长度
func (obj *OamDevice) OamDeviceQueryResp(dataModel *bparammodel.BtsBaseParam, wCommand uint16, datalist []byte, wLen uint16) error {
	strTmp := ""

	switch wCommand {
	case ORDER_DEVICE_TYPE:
		dataModel.BtsType = datalist[0]
	case ORDER_DEVICE_SERIAL_NO:
		strTmp = string(datalist)
		strTmp = util.RemoveNullChars(strTmp)
		dataModel.SerialNumber = strTmp
	case ORDER_DEVICE_MODEL:
		strTmp = string(datalist)
		strTmp = util.RemoveNullChars(strTmp)
		dataModel.BtsModel = strTmp
	case ORDER_DEVICE_MCU_VERSION:
		strTmp = string(datalist)
		strTmp = util.RemoveNullChars(strTmp)
		dataModel.SoftVersion = strTmp
	case ORDER_DEVICE_PROJECT_ID:
		dataModel.ProjectID = int(binary.LittleEndian.Uint32(datalist[0:4]))
	case ORDER_DEVICE_BLE_BTS_NAME:
		strTmp = string(datalist)
		strTmp = util.RemoveNullChars(strTmp)
		dataModel.BleName = strTmp
	case ORDER_DEVICE_WIFI_BTS_NAME:
		strTmp = string(datalist)
		strTmp = util.RemoveNullChars(strTmp)
		dataModel.WifiName = strTmp
	default:
		break
	}

	return nil
}
