net

package
v0.0.0-...-2266a13 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UUID                = "22e0e945-cc6e-4a9a-955f-f8f12350cb14"
	SSID_CHARACTERISTIC = "22e0e946-cc6e-4a9a-955f-f8f12350cb14"
	PASS_CHARACTERISTIC = "22e0e947-cc6e-4a9a-955f-f8f12350cb14"
	IP_CHARACTERISTIC   = "22e0e948-cc6e-4a9a-955f-f8f12350cb14"
	PORT_CHARACTERISTIC = "22e0e949-cc6e-4a9a-955f-f8f12350cb14"
	UUID_CHARACTERISTIC = "22e0e950-cc6e-4a9a-955f-f8f12350cb14"
	DONE_CHARACTERISTIC = "22e0e951-cc6e-4a9a-955f-f8f12350cb14"

	BLE_ON           = 1
	BLE_OFF          = 0
	BLE_SCANNING     = 2
	BLE_CONNECTING   = 3
	BLE_CONNECTED    = 4
	BLE_DISCONNECTED = 5
	BLE_ERROR        = 6
	BLE_FOUND        = 7
	BLE_SUCCESS      = 8
	MAX_BLE_BYTES    = 96
)
View Source
const (
	NO_DEVICE = iota
	DEVICE_CONNECTED
	DEVICE_SCANNING
	DEVICE_ON
	DEVICE_DISCONNECTED
	KILL
	CONTINUE
)
View Source
const (
	GPR_RECIEVE = 1
	GPR_ERROR   = 2
)
View Source
const ACK = 7
View Source
const APPLICATION_PORT = 9060
View Source
const ARBITRATE = 5
View Source
const BUSY = 10
View Source
const CONNECTED = 2
View Source
const CS_BLUE = "\033[34m"
View Source
const CS_GREEN = "\033[32m"
View Source
const CS_RED = "\033[31m"
View Source
const CS_WHITE = "\033[37m"
View Source
const CS_YELLOW = "\033[33m"
View Source
const DEFAULT_BAUD = 9600
View Source
const DISCONNECTED = 3
View Source
const ERROR = 11
View Source
const EXIT = 1
View Source
const HANDSHAKE = 2
View Source
const IDLE = 0
View Source
const MAX_LOSS_RATE = 0.1
View Source
const NACK = 8
View Source
const NOT_READY = 0
View Source
const OUTBOX = 9
View Source
const READY = 1
View Source
const RECONNECTED = 4
View Source
const RESOLVED = 6
View Source
const TIMEOUT = 30

Connection Status

Variables

This section is empty.

Functions

func ByteToIP

func ByteToIP(bytes []byte) net.IP

func GenMessageID

func GenMessageID() uint32

func IPV4Address

func IPV4Address() *net.TCPAddr

func Int32ToIP

func Int32ToIP(in uint32) net.IP

Types

type BLECharacteristic

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

type BluetoothConnection

type BluetoothConnection struct {
	Names map[string]string

	Status chan int
	// contains filtered or unexported fields
}

func NewBluetoothConnection

func NewBluetoothConnection() (*BluetoothConnection, error)

func (*BluetoothConnection) Close

func (conn *BluetoothConnection) Close()

func (*BluetoothConnection) Connect

func (conn *BluetoothConnection) Connect(device int, params bluetooth.ConnectionParams) error

func (*BluetoothConnection) Read

func (conn *BluetoothConnection) Read(uuid string) ([]byte, error)

func (*BluetoothConnection) Scan

func (conn *BluetoothConnection) Scan() error

Available returns a list of available devices

func (*BluetoothConnection) ScanUUID

func (conn *BluetoothConnection) ScanUUID(uuid string) error

func (*BluetoothConnection) Service

func (conn *BluetoothConnection) Service(uuid string) *bluetooth.DeviceService

func (*BluetoothConnection) Write

func (conn *BluetoothConnection) Write(uuid string, data []byte) error

type IP

type IP struct {
	IP net.IP
}

func (*IP) String

func (ip *IP) String() string

func (*IP) To16

func (ip *IP) To16() []byte

func (*IP) To4

func (ip *IP) To4() []byte

type Protobuf

type Protobuf struct {
	Ack                proto.Ack
	Cmd                proto.Command
	CmdBufferQueue     proto.CommandBufferQueue
	SyncCmdBufferQueue proto.SyncCommandBufferQueue
	DataBuffer         proto.DataBuffer
	MultiDataBuffer    proto.MultiDataBuffer
	Start              proto.Start
	Stop               proto.Stop
	GetProfile         proto.GetProfile
	DeviceProfile      proto.DeviceProfile
	Error              proto.Error
	// contains filtered or unexported fields
}

func NewProtobuf

func NewProtobuf() *Protobuf

type Stopwatch

type Stopwatch struct {
	StartTime int64
	EndTime   int64
	Interval  int64
}

func NewStopwatch

func NewStopwatch() *Stopwatch

func (*Stopwatch) GetInterval

func (p *Stopwatch) GetInterval() int64

func (*Stopwatch) Reset

func (p *Stopwatch) Reset()

func (*Stopwatch) Start

func (p *Stopwatch) Start()

func (*Stopwatch) Stop

func (p *Stopwatch) Stop()

type TCPConnection

type TCPConnection struct {
	Conn   *net.TCPConn
	Addr   *net.TCPAddr
	MyAddr *net.TCPAddr
	Talker *Talker
	Status int
}

TCPConnection is a struct that contains the TCP connection, address, and message

func NewTCPConnection

func NewTCPConnection(addressport string) (*TCPConnection, error)

TCPBroadcast is a function that sends a TCP broadcast message, we send a specialized message for connection

func (*TCPConnection) Close

func (u *TCPConnection) Close()

func (*TCPConnection) Listen

func (u *TCPConnection) Listen(status chan int, message_id uint32, buffer_size int, proto_handler func([]byte, uint32) (proto.Message, error))

func (*TCPConnection) Send

func (u *TCPConnection) Send(bytes []byte) (int, error)

type Talker

type Talker struct {
	Mode       int // Send/Recieve Mode
	Local      Protobuf
	Remote     Protobuf
	Connection *TCPConnection
}

func NewTalker

func NewTalker(conn *TCPConnection) *Talker

func (*Talker) Listen

func (t *Talker) Listen(m chan int, message_id uint32, handler func([]byte, uint32) (pr.Message, error))

func (*Talker) Receive

func (t *Talker) Receive(message []byte, message_id uint32) error

func (*Talker) RecieveAck

func (t *Talker) RecieveAck(msg []byte, message_id uint32) (pr.Message, error)

func (*Talker) RecieveDataBuffer

func (t *Talker) RecieveDataBuffer(msg []byte, message_id uint32) (pr.Message, error)

func (*Talker) RecieveDeviceProfile

func (t *Talker) RecieveDeviceProfile(msg []byte, message_id uint32) (pr.Message, error)

func (*Talker) RecieveError

func (t *Talker) RecieveError(msg []byte, message_id uint32) (pr.Message, error)

func (*Talker) RecieveMultiDataBuffer

func (t *Talker) RecieveMultiDataBuffer(msg []byte, message_id uint32) (pr.Message, error)

func (*Talker) SendAck

func (t *Talker) SendAck(message_id uint32) error

func (*Talker) SendCommand

func (t *Talker) SendCommand(message_id uint32) error

func (*Talker) SendCommandBufferQueue

func (t *Talker) SendCommandBufferQueue(message_id uint32) error

func (*Talker) SendDataBuffer

func (t *Talker) SendDataBuffer(message_id uint32) error

func (*Talker) SendError

func (t *Talker) SendError(message_id uint32) error

func (*Talker) SendGetDeviceProfile

func (t *Talker) SendGetDeviceProfile(message_id uint32) error

func (*Talker) SendGetProfile

func (t *Talker) SendGetProfile(message_id uint32) error

func (*Talker) SendMultiDataBuffer

func (t *Talker) SendMultiDataBuffer(message_id uint32) error

func (*Talker) SendStart

func (t *Talker) SendStart(message_id uint32) error

func (*Talker) SendStop

func (t *Talker) SendStop(message_id uint32) error

func (*Talker) SendSyncCommandBufferQueue

func (t *Talker) SendSyncCommandBufferQueue(message_id uint32) error

Jump to

Keyboard shortcuts

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