gopdu

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 7 Imported by: 0

README

Source package for Encode/Decode Packet Data Unit (PDU) (7bit, UCS2)

  • If your app using GSM SMS functionality
  • Asterisk
  • Some tests
Functionality
  • Decode PDU to normal texts
  • Encode normal texts to PDU
Add to use
go get github.com/KusoKaihatsuSha/gopdu.git
Sample
see in test file

Documentation

Overview

Source package for Encode/Decode Packet Data Unit (PDU) (7bit, UCS2)

Example (Decode_to_PDU)
dec := SMS{}
dec.Decode(t01)
dec.Decode(t02)
dec.Decode(t03)
dec.Decode(t04)
dec.Decode(t05)
dec.Decode(t06)
dec.Decode(t07)
dec.Decode(t08)
dec.Decode(t09)
dec.Decode(t10)
dec.Decode(t11)
dec.MergeTextToFirst()
sort_ := []string{}
for k, v := range dec {
	if v.Part <= 1 {
		sort_ = append(sort_, k.(string))
	}
}
sort.Slice(sort_, func(i, j int) bool {
	return sort_[i] < sort_[j]
})
for _, v := range sort_ {
	fmt.Println(dec[v].Text)
}
Output:

Howdy y'all!
hellohello
hellohello
How are you?
It is easy to read text messages via AT commands.
This is an SMS PDU example from smspdu.com
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
This is an SMS PDU example from smspdu.com
A flash message!

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SMS

type SMS map[any]SMSone

func Encode

func Encode(text string, phone string) SMS

Encode(string, string) SMS encode to pdu

func (SMS) Decode

func (obj SMS) Decode(pdu string)

Decode(string) decode pdu string

func (*SMS) MergeTextToFirst

func (obj *SMS) MergeTextToFirst()

MergeTextToFirst() merge multipart sms text into first

func (*SMS) PrintDebug

func (obj *SMS) PrintDebug()

PrintDebug() debug

type SMSone

type SMSone struct {
	Pdu                        string `json:"pdu"`
	ServiceCenterAddressLength int
	ServiceCenterAddressType   string
	ServiceCenterAddress       string
	MessageType                string
	ReplyPath                  string
	UserDataHeaderIncluded     string
	StatusReportRequest        string
	ValidityPeriodFormat       string
	RejectDuplicates           string
	MessageTypeIndicator       string
	MessageReference           string
	AddressLength              int
	AddressType                string
	Address                    string
	ProtocolIdentifier         string
	DataCodingScheme           string
	DataCodingSchemeIs7        bool
	ValidityPeriod             int
	ValidityPeriodSecond       int
	UserDataLength             string
	UserData                   string
	FirstSymbol                string
	Text                       string `json:"text"`
	Date                       string `json:"date"`
	Parts                      int    `json:"parts"`
	Part                       int    `json:"part"`
	Point                      int
	UserDataHeaderLength       int
	UserDataHeader             string
}

Jump to

Keyboard shortcuts

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