Added signal check.

This commit is contained in:
Andrey Egorov
2024-08-10 15:21:27 +03:00
parent 75d05f197c
commit d21ad0ce00
5 changed files with 169 additions and 28 deletions

View File

@ -5,6 +5,7 @@ import (
"io"
"log"
"strings"
"time"
"gitea.unprism.ru/KRBL/sim-modem/api/modem/at"
)
@ -40,7 +41,7 @@ func (d *dialer) Init() error {
}
// Setup prefered message storage
if err := d.setupMsgSt(); err != nil {
return fmt.Errorf("setup msg storage: %w", err)
d.logger.Printf("ERROR setup msg storage: %s\n", err.Error())
}
// Check number
if resp, err := d.port.Send("AT+CNUM"); err != nil || !resp.Check() {
@ -57,7 +58,7 @@ func (d *dialer) Send(number, msg string) error {
return err
}
d.logger.Println(sresp)
resp, err := d.port.RawSend(fmt.Sprintf("%s\x1A", msg)) // Add additional \r\n because there is not supposed to be
resp, err := d.port.RawSend(fmt.Sprintf("%s\x1A", msg), time.Millisecond) // Add additional \r\n because there is not supposed to be
if err != nil {
return fmt.Errorf("message request: %w", err)
}