sim-modem/api/modem/at/response.go

25 lines
385 B
Go
Raw Normal View History

2024-07-23 09:22:53 +00:00
package at
type Resp string
const RespNil = Resp("")
func (resp Resp) Check() bool {
return len(resp) >= 2 && resp[len(resp)-2:] == "OK"
}
func (resp Resp) RmFront(str string) Resp {
2024-08-08 12:56:23 +00:00
if !resp.Check() {
return RespNil
}
2024-07-23 09:22:53 +00:00
return Resp(string(resp)[len(str):])
}
2024-07-23 14:26:24 +00:00
func (resp Resp) String() string {
2024-07-23 09:22:53 +00:00
return string(resp)
}
2024-07-28 18:01:18 +00:00
func (resp Resp) Bytes() []byte {
return []byte(resp)
}