26 lines
580 B
Go
26 lines
580 B
Go
package rawPayloadPrinter
|
|
|
|
import (
|
|
"log"
|
|
"fmt"
|
|
"encoding/base64"
|
|
"encoding/hex"
|
|
"udi/database"
|
|
)
|
|
|
|
|
|
func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]database.VariableType, _ *map[string]interface{}, _ *database.Device) error {
|
|
if fPort != 2 {
|
|
return fmt.Errorf("Unexpected fPort %d", fPort)
|
|
}
|
|
|
|
bytes, err := base64.StdEncoding.DecodeString(frmPayload)
|
|
if err != nil {
|
|
return fmt.Errorf("Unable to base64-decode payload: %v", err)
|
|
}
|
|
hexString := hex.EncodeToString(bytes)
|
|
|
|
log.Printf("Payload: %s", hexString)
|
|
return nil
|
|
}
|