Skip to content

Commit 379970a

Browse files
Gleb Mitinxlab
authored andcommitted
Exported callID channel type
1 parent d99f011 commit 379970a

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

at.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/xlab/at/calls"
1011
"github.com/xlab/at/pdu"
1112
"github.com/xlab/at/sms"
1213
)
@@ -60,7 +61,7 @@ type Device struct {
6061
cmdPort *os.File
6162
notifyPort *os.File
6263

63-
incomingCallerIDs chan *callerIDReport
64+
incomingCallerIDs chan *calls.CallerID
6465
messages chan *sms.Message
6566
ussd chan Ussd
6667
updated chan struct{}
@@ -70,7 +71,7 @@ type Device struct {
7071
}
7172

7273
// IncomingCallerID fires when an incoming caller ID was received.
73-
func (d *Device) IncomingCallerID() <-chan *callerIDReport {
74+
func (d *Device) IncomingCallerID() <-chan *calls.CallerID {
7475
return d.incomingCallerIDs
7576
}
7677

@@ -264,7 +265,9 @@ func (d *Device) handleReport(str string) (err error) {
264265
if err = report.Parse(str); err != nil {
265266
return
266267
}
267-
d.incomingCallerIDs <- &report
268+
269+
callerID := report.GetCallerID()
270+
d.incomingCallerIDs <- callerID
268271
case Reports.Message:
269272
var report messageReport
270273
if err = report.Parse(str); err != nil {
@@ -391,7 +394,7 @@ func (d *Device) Init(profile DeviceProfile) error {
391394
}
392395
d.active = true
393396
d.closed = make(chan struct{})
394-
d.incomingCallerIDs = make(chan *callerIDReport, 100)
397+
d.incomingCallerIDs = make(chan *calls.CallerID, 100)
395398
d.messages = make(chan *sms.Message, 100)
396399
d.ussd = make(chan Ussd, 100)
397400
d.updated = make(chan struct{}, 100)

calls/calls.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package calls
2+
3+
type CallerID struct {
4+
CallerID string
5+
IDType int
6+
IDValidity int
7+
}

commands.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"strings"
77

8+
"github.com/xlab/at/calls"
89
"github.com/xlab/at/pdu"
910
"github.com/xlab/at/sms"
1011
"github.com/xlab/at/util"
@@ -266,6 +267,14 @@ func (c *callerIDReport) Parse(str string) (err error) {
266267
return nil
267268
}
268269

270+
func (c *callerIDReport) GetCallerID() *calls.CallerID {
271+
return &calls.CallerID{
272+
CallerID: c.CallerID,
273+
IDType: c.IDType.ID,
274+
IDValidity: c.IDValidity.ID,
275+
}
276+
}
277+
269278
type messageReport struct {
270279
Memory StringOpt
271280
Index uint16

0 commit comments

Comments
 (0)