pdumode

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 3 Imported by: 7

Documentation

Overview

Package pdumode provides functions to encode and decode PDU mode frames exchanged with a GSM modem in PDU mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PDU

type PDU struct {
	// SMCS Address
	SMSC SMSCAddress

	// TPDU in binary form
	TPDU []byte
}

PDU represents the PDU exchanged with the GSM modem.

func UnmarshalBinary

func UnmarshalBinary(src []byte) (p *PDU, err error)

UnmarshalBinary decodes the binary form of the PDU provided by the modem.

Returns the unmarshalled PDU, or an error if unmarshalling fails.

func UnmarshalHexString

func UnmarshalHexString(s string) (p *PDU, err error)

UnmarshalHexString decodes the hex string provided by the modem.

func (*PDU) MarshalBinary

func (p *PDU) MarshalBinary() ([]byte, error)

MarshalBinary marshals the PDU into binary form.

func (*PDU) MarshalHexString

func (p *PDU) MarshalHexString() (string, error)

MarshalHexString encodes the PDU into the hex string expected by the modem.

func (*PDU) UnmarshalBinary

func (p *PDU) UnmarshalBinary(src []byte) error

UnmarshalBinary decodes the binary form of the PDU provided by the modem.

func (*PDU) UnmarshalHexString

func (p *PDU) UnmarshalHexString(s string) error

UnmarshalHexString decodes the hex string provided by the modem.

type SMSCAddress

type SMSCAddress struct {
	tpdu.Address
}

SMSCAddress is the address of the SMSC.

The SMCSAddress is similar to a TPDU Address, but the binary form is marshalled differently, hence the subtype.

The Type-of-number should typically be TonNational or TonInternational, but that is not enforced.

The NumberingPlan should typically be NpISDN, but that is not enforced either.

func (*SMSCAddress) MarshalBinary

func (a *SMSCAddress) MarshalBinary() (dst []byte, err error)

MarshalBinary marshals the SMSC Address into binary.

func (*SMSCAddress) UnmarshalBinary

func (a *SMSCAddress) UnmarshalBinary(src []byte) (int, error)

UnmarshalBinary unmarshals an SMSC Address from a TPDU field.

It returns the number of bytes read from the source, and any error detected while decoding.

Jump to

Keyboard shortcuts

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