pdumode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pdumode provides functions to encode messages to transmit SMSs, and decode messages received SMSs, via a GSM modem in PDU mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct{}

Decoder converts a PDU into the SMSC address and TPDU that it contains.

func (Decoder) Decode

func (Decoder) Decode(src []byte) (*SMSCAddress, []byte, error)

Decode decodes the binary form of the PDU provided by the modem. The PDU is comprised of the SMSC address and the TPDU, which are returned. The TPDU is in binary form, ready to be unmarshalled.

func (Decoder) DecodeString

func (d Decoder) DecodeString(s string) (*SMSCAddress, []byte, error)

DecodeString decodes the hex string provided by the modem. The PDU is comprised of the SMSC address and the TPDU, which are returned. The TPDU is in binary form, ready to be unmarshalled.

type Encoder

type Encoder struct{}

Encoder converts an SMSC address and TPDU into a PDU.

func (Encoder) Encode

func (Encoder) Encode(smsc SMSCAddress, tpdu []byte) ([]byte, error)

Encode marshals the PDU into binary form. The PDU is comprised of the SMSC address and the TPDU. The TPDU has been marshalled into binary and is ready to be transmitted.

func (Encoder) EncodeToString

func (e Encoder) EncodeToString(smsc SMSCAddress, tpdu []byte) (string, error)

EncodeToString encodes the PDU into the hex string expected by the modem. The PDU is comprised of the SMSC address and the TPDU. The TPDU is in binary ready to be transmitted.

type SMSCAddress

type SMSCAddress 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