sms

package
v0.0.0-...-e32b96d Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sms allows to encode and decode SMS messages into/from PDU format as described in 3GPP TS 23.040.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownEncoding    = errors.New("sms: unsupported encoding")
	ErrUnknownMessageType = errors.New("sms: unsupported message type")
	ErrIncorrectSize      = errors.New("sms: decoded incorrect size of field")
	ErrNonRelative        = errors.New("sms: non-relative validity period support is not implemented yet")
)

Common errors.

View Source
var Encodings = struct {
	Gsm7Bit Encoding
	UCS2    Encoding
}{
	0x00, 0x08,
}

Encodings represent the possible encodings of message's text data.

View Source
var MessageTypes = struct {
	Deliver       MessageType
	DeliverReport MessageType
	StatusReport  MessageType
	Command       MessageType
	Submit        MessageType
	SubmitReport  MessageType
}{
	0x00, 0x00,
	0x02, 0x02,
	0x01, 0x01,
}

MessageTypes represent the possible message's types (3GPP TS 23.040).

View Source
var ValidityPeriodFormats = struct {
	FieldNotPresent ValidityPeriodFormat
	Relative        ValidityPeriodFormat
	Enhanced        ValidityPeriodFormat
	Absolute        ValidityPeriodFormat
}{
	0x00, 0x02, 0x01, 0x03,
}

ValidityPeriodFormats represent the possible formats of message's validity period (3GPP TS 23.040).

Functions

This section is empty.

Types

type Encoding

type Encoding byte

Encoding represents the encoding of message's text data.

type Message

type Message struct {
	Type                 MessageType
	Encoding             Encoding
	VP                   ValidityPeriod
	VPFormat             ValidityPeriodFormat
	ServiceCenterTime    Timestamp
	ServiceCenterAddress PhoneNumber
	Address              PhoneNumber
	Text                 string

	// Advanced
	MessageReference         byte
	ReplyPathExists          bool
	UserDataStartsWithHeader bool
	StatusReportIndication   bool
	StatusReportRequest      bool
	MoreMessagesToSend       bool
	LoopPrevention           bool
	RejectDuplicates         bool
}

Message represents an SMS message, including some advanced fields. This is a user-friendly high-level representation that should be used around. Complies with 3GPP TS 23.040.

func (*Message) PDU

func (s *Message) PDU() (int, []byte, error)

PDU serializes the message into octets ready to be transferred. Returns the number of TPDU bytes in the produced PDU. Complies with 3GPP TS 23.040.

func (*Message) ReadFrom

func (s *Message) ReadFrom(octets []byte) (n int, err error)

ReadFrom constructs a message from the supplied PDU octets. Returns the number of bytes read. Complies with 3GPP TS 23.040.

type MessageType

type MessageType byte

MessageType represents the message's type.

type PhoneNumber

type PhoneNumber string

PhoneNumber represents the address in either local or international format.

func (PhoneNumber) PDU

func (p PhoneNumber) PDU() (int, []byte, error)

PDU returns the number of digits in address and octets of semi-octet encoded address.

func (*PhoneNumber) ReadFrom

func (p *PhoneNumber) ReadFrom(octets []byte)

ReadFrom constructs an address from the semi-decoded version in the supplied byte slice.

func (PhoneNumber) Type

func (p PhoneNumber) Type() byte

Type returns the type of address — local or international.

type Timestamp

type Timestamp time.Time

Timestamp represents message's timestamp.

func (Timestamp) PDU

func (t Timestamp) PDU() []byte

PDU returns bytes of semi-octet encoded timestamp.

func (*Timestamp) ReadFrom

func (t *Timestamp) ReadFrom(octets []byte)

ReadFrom reads a semi-encoded timestamp from the given octets.

type USSD

type USSD string

USSD represents an USSD query string

func (USSD) Gsm7Bit

func (u USSD) Gsm7Bit() []byte

Gsm7Bit encodes USSD query into GSM 7-Bit packed octets.

type ValidityPeriod

type ValidityPeriod time.Duration

ValidityPeriod represents the validity period of message.

func (ValidityPeriod) Octet

func (v ValidityPeriod) Octet() byte

Octet return a one-byte representation of the validity period.

func (*ValidityPeriod) ReadFrom

func (v *ValidityPeriod) ReadFrom(oct byte)

ReadFrom reads the validity period form the given byte.

type ValidityPeriodFormat

type ValidityPeriodFormat byte

ValidityPeriodFormat represents the format of message's validity period.

Jump to

Keyboard shortcuts

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