Skip to content

Commit

Permalink
chore: update lpac version
Browse files Browse the repository at this point in the history
  • Loading branch information
damonto committed Jun 16, 2024
1 parent 8d900c2 commit 5fb46b7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions internal/app/handler/modem.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ EID: %s
}
m.Lock()
info, err := lpac.NewCmd(context.Background(), usbDevice).Info()
ns, _ := lpac.NewCmd(context.Background(), usbDevice).NotificationList()
for _, n := range ns {
fmt.Println(n.ICCID)
}
m.Unlock()
if err != nil {
slog.Error("failed to get eUICC info", "error", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/app/handler/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (h *ProfileHandler) Handle(c telebot.Context) error {
})
}

func (h *ProfileHandler) toTextMessage(c telebot.Context, profiles []lpac.Profile) (string, *telebot.ReplyMarkup) {
func (h *ProfileHandler) toTextMessage(c telebot.Context, profiles []*lpac.Profile) (string, *telebot.ReplyMarkup) {
selector := &telebot.ReplyMarkup{}
template := `
%s *%s*
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/lpac/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const (
NotificationProfileManagementOperationDelete = "delete"
)

func (c *Cmd) NotificationList() ([]Notification, error) {
var notifications []Notification
func (c *Cmd) NotificationList() ([]*Notification, error) {
var notifications []*Notification
if err := c.Run([]string{"notification", "list"}, &notifications, nil); err != nil {
return notifications, err
}
Expand Down
16 changes: 8 additions & 8 deletions internal/pkg/lpac/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ var (
ErrProfileNotFound = errors.New("profile not found")
)

func (c *Cmd) ProfileList() ([]Profile, error) {
var profiles []Profile
func (c *Cmd) ProfileList() ([]*Profile, error) {
var profiles []*Profile
if err := c.Run([]string{"profile", "list"}, &profiles, nil); err != nil {
return profiles, err
}
return profiles, nil
}

func (c *Cmd) ProfileInfo(ICCID string) (Profile, error) {
var profiles []Profile
func (c *Cmd) ProfileInfo(ICCID string) (*Profile, error) {
var profiles []*Profile
if err := c.Run([]string{"profile", "list"}, &profiles, nil); err != nil {
return Profile{}, err
return nil, err
}

for _, profile := range profiles {
if profile.ICCID == ICCID {
return profile, nil
}
}
return Profile{}, ErrProfileNotFound
return nil, ErrProfileNotFound
}

func (c *Cmd) ProfileDownload(activationCode *ActivationCode, progress Progress) error {
Expand Down Expand Up @@ -138,8 +138,8 @@ func (c *Cmd) ProfileSetNickname(ICCID string, nickname string) error {
return c.Run([]string{"profile", "nickname", ICCID, nickname}, nil, nil)
}

func (c *Cmd) ProfileDiscovery() ([]DiscoveryResponse, error) {
var response []DiscoveryResponse
func (c *Cmd) ProfileDiscovery() ([]*DiscoveryResponse, error) {
var response []*DiscoveryResponse
if err := c.Run([]string{"profile", "discovery"}, &response, nil); err != nil {
return response, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/util/euicc.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type CertificateIssuer struct {
Name string `json:"name"`
}

var certificateIssuers []CertificateIssuer
var EUMs []EUM
var certificateIssuers []*CertificateIssuer
var EUMs []*EUM

func init() {
if err := json.Unmarshal(eum, &EUMs); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func init() {

flag.StringVar(&config.C.BotToken, "bot-token", "", "telegram bot token")
flag.Int64Var(&config.C.AdminId, "admin-id", 0, "telegram admin id")
flag.StringVar(&config.C.Version, "version", "v2.0.1", "the version of lpac to download")
flag.StringVar(&config.C.Version, "version", "v2.0.2", "the version of lpac to download")
flag.StringVar(&config.C.Dir, "dir", dir, "the directory to store lpac")
flag.BoolVar(&config.C.DontDownload, "dont-download", false, "don't download lpac binary")
flag.BoolVar(&config.C.Verbose, "verbose", false, "enable verbose mode")
Expand Down

0 comments on commit 5fb46b7

Please sign in to comment.