feat: add display record command and refactor training command

This commit is contained in:
2022-06-09 12:19:54 +02:00
parent 02db9e241e
commit 8b8d53af58
8 changed files with 255 additions and 47 deletions

View File

@ -33,7 +33,7 @@ type Recorder struct {
cancel chan interface{}
}
var RecorNameFormat = "record_%s.json"
var FileNameFormat = "record_%s.json"
func (r *Recorder) Start() error {
err := service.RegisterCallback(r.client, r.recordTopic, r.onRecordMsg)
@ -75,7 +75,7 @@ func (r *Recorder) onRecordMsg(_ mqtt.Client, message mqtt.Message) {
}
jsonDir := fmt.Sprintf("%s/", recordDir)
recordName := fmt.Sprintf("%s/%s", jsonDir, fmt.Sprintf(RecorNameFormat, msg.GetFrame().GetId().GetId()))
recordName := fmt.Sprintf("%s/%s", jsonDir, fmt.Sprintf(FileNameFormat, msg.GetFrame().GetId().GetId()))
err = os.MkdirAll(jsonDir, os.FileMode(0755))
if err != nil {
l.Errorf("unable to create %v directory: %v", jsonDir, err)