package m9z

import (
	"github.com/gogf/gf/v2/errors/gerror"
	"log"
)

// 编程模式0~2，默认为0模式。0x00~0x02
// 对应模式01~模式03
func ModeRead(deviceId string) (byte, error) {
	readResp, err := ReadCmd(deviceId, mode, "读取模式")
	if err != nil {
		return 0, nil
	}
	log.Printf("readResp.Data % X", readResp.Data)
	return readResp.Data[0], nil
}
func ModeWrite(deviceId string, m byte) error {
	writeResp, err := WriteCmd(deviceId, mode, []byte{m}, "写入模式")
	if err != nil {
		return err
	}
	if !writeResp.Success {
		return gerror.New("设置失败")
	}
	return nil
}
