vehicle

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DeviceNotFound       = errors.New("device not found")
	SNNotValidError      = errors.New("sn text is not valid")
	DeviceNotOnlineError = errors.New("device is not online")
)

Functions

This section is empty.

Types

type ClearPrivilegePacket

type ClearPrivilegePacket struct {
	Header
	Flag []byte `struc:"[4]byte"`
	Pad  []byte `struc:"[52]pad"`
}

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector 蓝牙控制卡连接器,用于控制车行门禁

func NewConnector

func NewConnector(port int, logger log.Logger) *Connector

NewConnector 创建蓝牙控制卡连接器 port-UDP服务监听的端口,用于接收刷卡事件

func (*Connector) AddDevice

func (c *Connector) AddDevice(sn string, serialNum uint32, ip string) error

AddDevice 添加设备 sn 唯一任意值 serialNum 控制卡的序列号 ip 控制卡IP port 控制卡port,一般为60000

func (*Connector) AddPrivilege

func (c *Connector) AddPrivilege(sn string, cardNum uint32) error

AddPrivilege 添加卡

func (*Connector) ClearPrivilege

func (c *Connector) ClearPrivilege(sn string) error

ClearPrivilege 清空卡号

func (*Connector) Destroy

func (c *Connector) Destroy() error

func (*Connector) Discovery

func (c *Connector) Discovery() (device []SearchedDevice, err error)

func (*Connector) GetSwipeEvent

func (c *Connector) GetSwipeEvent() chan SwipeData

func (*Connector) Initialize

func (c *Connector) Initialize() error

func (*Connector) RemoveDevice

func (c *Connector) RemoveDevice(sn string) error

func (*Connector) RemovePrivilege

func (c *Connector) RemovePrivilege(sn string, cardNum uint32) error

RemovePrivilege 删除卡号

type DiscoveryResponse

type DiscoveryResponse struct {
	Header
	IP      []uint8 `struc:"[4]uint8"`
	Mask    []uint8 `struc:"[4]uint8"`
	Gateway []uint8 `struc:"[4]uint8"`
	Mac     []byte  `struct:"[6]byte"`
}

func (DiscoveryResponse) IPString

func (d DiscoveryResponse) IPString() string

func (DiscoveryResponse) MacString

func (d DiscoveryResponse) MacString() string
type Header struct {
	Magic []byte `struc:"[4]byte"`
	SN    uint32 `struc:"uint32,little"`
}

func (Header) SNString

func (d Header) SNString() string

type RecordResponse

type RecordResponse struct {
	Header
	RecordIndex uint   `struc:"uint32"`
	RecordType  uint8  `struc:"uint8"`
	Pass        uint8  `struc:"uint8"`
	DoorNum     uint8  `struc:"uint8"`
	Direction   uint8  `struc:"uint8"`
	CardNum     uint32 `struc:"uint32,little"`
	Date        []byte `struc:"[7]byte"`
}

type RemovePrivilegePacket

type RemovePrivilegePacket struct {
	Header
	CardNum uint32 `struc:"uint32,little"`
	Pad     []byte `struc:"[52]pad"`
}

type SearchedDevice

type SearchedDevice struct {
	SerialNum uint32 `json:"serial_num"`
	Mac       string `json:"mac"`
	IP        string `json:"ip"`
}

type StatusResponse

type StatusResponse struct {
	Header
	LastIndex  uint8  `struc:"uint8"`
	RecordType uint8  `stuc:"uint8"`
	Pass       uint8  `struc:"uint8"`
	DoorNum    uint8  `struc:"uint8"`
	Direction  uint8  `struc:"uint8"`
	CardNum    uint   `struc:"uint32,little"`
	Date       []byte `struc:"[7]byte"`
}

type SwipeData

type SwipeData struct {
	SN        string `json:"sn"`
	Pass      uint8  `json:"pass"`
	DoorNum   uint8  `json:"door_num"`
	Direction uint8  `json:"direction"`
	CarNum    uint32 `json:"car_num"`
}

func (SwipeData) String

func (sd SwipeData) String() string

type UploadPrivilegePacket

type UploadPrivilegePacket struct {
	Header
	CardNum   uint32  `struc:"uint32,little"`
	StartDate []uint8 `struc:"[4]uint8"`
	EndDate   []uint8 `struc:"[4]uint8"`
	DoorOne   bool    `struc:"bool"`
	DoorTwo   bool    `struc:"bool"`
	DoorThree bool    `struc:"bool"`
	DoorFour  bool    `struc:"bool"`
	Pad       []byte  `struc:"[40]pad"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL