Giter Site home page Giter Site logo

estevaofv / esp-update-over-rs485 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emelianov/esp-update-over-rs485

0.0 1.0 0.0 55 KB

Sending files and firmware updates over Serial/RS-485. Works with ESP8266/ESP32

License: MIT License

C++ 100.00%

esp-update-over-rs485's Introduction

esp-Update-over-RS485

1. High level API

class SerialUpdate<HardwareSerial>|<SoftwareSerial> {
	String version;	// Filled with slave current version on slave init (begin())
	SerialUpdate(<HardwareSerial>|<SoftwareSerial>, uint16_t tx);	// Master build constructor
	SerialUpdate(<HardwareSerial>|<SoftwareSerial>, const char* ver = "", uint8_t id = 0);	// Slave constructor
	void begin(uint8_t slaveId = 0);	// Initialize connection to slave
	bool isIdle();	// from RSerial
	bool isReady();	// Actually chcks if version is not ""
	bool sendFile(char* name, File dataSource);		// Send file to slave
	bool sendUpdate(File dataSource);		// Send firmware update to slave
	bool cancel();		// Cancel current send operation
}
Loop functions:
	status_t taskMaster();	// from RSerial
	status_t taskSlave();	// from RSerial

// Update/Transfer commands
// CANCEL_ALL	Cancel current operation
// GET_VERSION	Get/Send version
// BEGIN_UPDATE	Initiate Update
// IMAGE_DATA	Push image data
// END_UPDATE	Finalize update
// FILE_CREATE	Begin file transfer
// FILE_DATA	Push file data
// FILE_CLOSE	Finalize file transfer
// FILE_ERROR	Unrecovarable file/update operation error (Unable to create file, Update or file write error)

2. Packet exchange protocol API

struct packetHeader {
	uint8_t sig[MAGIC_SIG_LENGTH];	// Packet signature
	uint8_t id;						// From/To slave ID
	uint32_t seq;					// Packet sequence #
	uint8_t command;
	uint16_t dataSize;				// Packet data size (Full packet size is sizeof(header) + data size + sizeof(crc32)
};

// Basic commands available
// C_OK	Packet is succefully processed (CRC is Ok no other errors)
// C_ERROR	General packet processing error (structure error or packet oversized)
// C_PING	Ping request/Reply
// C_BADCRC	Packet CRC mismach

union packetFrame {
	packetHeader header;
	uint8_t raw[FRAME_LENGTH];
};

class RSerial<HardwareSerrila>|<SoftwareSerial> {
	RSerial(HardwareSerial|SoftwareSerial serial);
	RSerial(HardwareSerial|SoftwareSerial serial, int16_t max485_tx);
	status_t taskSlave();
	status_t taskMaster();
	void clean();
	status_t send();
	status_t receive();
	virtual status_t processPacketMaster();
	virtual status_t processPacketSlave();
	bool isIdle();
	bool fillFrame(uint8_t com, const char* data, uint8_t slaveId = 0);
	bool fillFrame(uint8_t com, const uint8_t* data, uint16_t len, uint8_t slaveId = 0);
	bool fillFrame(uint8_t com, File data, uint8_t slaveId = 0);
	bool fillFrame(uint8_t com, const R &data, uint8_t slaveId = 0);	// Not tested
};

3. Resources used

Contributions

https://github.com/emelianov/esp-Update-over-RS485

Alexander Emelianov [email protected]

esp-update-over-rs485's People

Contributors

emelianov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.