Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/xlab/at

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/xlab/at

  • v0.0.0-20240804190732-c1b18c698ca6
  • Source
  • Go
  • Socket score

Version published
Created
Source

AT

Go Reference Build Status Coverage

Package at is a framework for communication with AT-compatible devices like Huawei modems via serial port. Currently this package is well-suited for Huawei devices and since AT-commands set may vary from device to device, sometimes you'll be forced to implement some logic by yourself.

Installation

go get github.com/xlab/at

Full documentation: godoc.

Features

This framework includes facilities for device monitoring, sending and receiving AT-commands, encoding and decoding SMS messages from or to PDU octet representation (as specified in 3GPP TS 23.040). An example of incoming SMS monitor application is given in example/daemon.

Examples

To get an SMS in a PDU octet representation:

smsSubmitGsm7 := Message{
	Text:                 "hello world",
	Encoding:             Encodings.Gsm7Bit,
	Type:                 MessageTypes.Submit,
	Address:              "+79261234567",
	ServiceCenterAddress: "+79262000331",
	VP:                   ValidityPeriod(time.Hour * 24 * 4),
	VPFormat:             ValidityPeriodFormats.Relative,
}
n, octets, err := smsSubmitGsm7.PDU()

To open a modem device:

dev = &Device{
	CommandPort: CommandPortPath,
	NotifyPort:  NotifyPortPath,
}
if err = dev.Open(); err != nil {
	return
}

If you're going to use this framework and its methods instead of plain R/W you should initialize the modem beforehand:

if err = dev.Init(DeviceE173()); err != nil {
	return
}

To use the wrapped version of a command:

err = dev.Commands.CUSD(UssdResultReporting.Enable, pdu.Encode7Bit(`*100#`), Encodings.Gsm7Bit)

Or to send a completely generic command:

str, err := dev.Send(`AT+GMM`)
log.Println(str, err)

Device-specific config

In order to introduce your own logic (i.e. custom modem Init function), you should derive your profile from the default DeviceProfile and override its methods.

License

MIT

FAQs

Package last updated on 04 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc