move NormalChannel and Transmitter to io pkg

This commit is contained in:
Andrea Franz 2019-03-28 11:33:48 +01:00
parent 1f5f2a9eeb
commit 5170838949
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D

View File

@ -1,10 +1,14 @@
package globalplatform
package io
import (
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/keycard-go/apdu"
"github.com/status-im/keycard-go/globalplatform"
"github.com/status-im/keycard-go/hexutils"
)
var logger = log.New("package", "io")
// Transmitter defines an interface with one method to transmit raw commands and receive raw responses.
type Transmitter interface {
Transmit([]byte) ([]byte, error)
@ -41,8 +45,8 @@ func (c *NormalChannel) Send(cmd *apdu.Command) (*apdu.Response, error) {
return nil, err
}
if resp.Sw1 == Sw1ResponseDataIncomplete && (cmd.Cla != ClaISO7816 || cmd.Ins != InsGetResponse) {
getResponse := NewCommandGetResponse(resp.Sw2)
if resp.Sw1 == globalplatform.Sw1ResponseDataIncomplete && (cmd.Cla != globalplatform.ClaISO7816 || cmd.Ins != globalplatform.InsGetResponse) {
getResponse := globalplatform.NewCommandGetResponse(resp.Sw2)
return c.Send(getResponse)
}