Skip to content

Commit

Permalink
Add dummy read after recv code is loaded.
Browse files Browse the repository at this point in the history
Use filepath.Base when sending the filename.
  • Loading branch information
matiasinsaurralde committed Jan 13, 2021
1 parent f8a254c commit 9a536eb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nodemcu/nodemcu.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -247,19 +248,19 @@ func (n *NodeMCU) SendFile(inputFile string) error {

n.logger.Println("SendFile is called, loading recv code")
n.WriteString(recvCode)
n.ReadStrings()
n.port.Flush()
time.Sleep(1 * time.Second)
n.logger.Println("Calling recv()")
n.WriteString("recv()\r\n")
n.port.Flush()
time.Sleep(1 * time.Second)

if !n.ReadyToRecv() {
return errNotReady
}
n.logger.Println("Device is ready to receive data")

filename := []byte(inputFile)
filename := []byte(filepath.Base(inputFile))
filename = append(filename, 0)
n.logger.Println("Passing filename to recv()")
n.port.Write(filename)
Expand Down

0 comments on commit 9a536eb

Please sign in to comment.