OTA Bootloader
- including adjustments to library header files to allow usage across C (bootloader) and C++ (firmware sketches) - including definition of new message types for firmware config and firmware code
This commit is contained in:
@@ -12,9 +12,11 @@
|
||||
#ifndef MyMessage_h
|
||||
#define MyMessage_h
|
||||
|
||||
#include <SPI.h>
|
||||
#ifdef __cplusplus
|
||||
#include <Arduino.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#define PROTOCOL_VERSION 2
|
||||
#define MAX_MESSAGE_LENGTH 32
|
||||
@@ -56,7 +58,8 @@ typedef enum {
|
||||
|
||||
// Type of data stream (for streamed message)
|
||||
typedef enum {
|
||||
ST_FIRMWARE, ST_SOUND, ST_IMAGE
|
||||
ST_FIRMWARE_CONFIG_REQUEST, ST_FIRMWARE_CONFIG_RESPONSE, ST_FIRMWARE_REQUEST, ST_FIRMWARE_RESPONSE,
|
||||
ST_SOUND, ST_IMAGE
|
||||
} stream;
|
||||
|
||||
typedef enum {
|
||||
@@ -101,7 +104,7 @@ typedef enum {
|
||||
#define miSetLength(_length) BF_SET(version_length, _length, 3, 5)
|
||||
#define miSetPayloadType(_pt) BF_SET(command_ack_payload, _pt, 4, 4)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
class MyMessage
|
||||
{
|
||||
public:
|
||||
@@ -144,6 +147,13 @@ public:
|
||||
MyMessage& set(unsigned int value);
|
||||
MyMessage& set(int value);
|
||||
|
||||
#else
|
||||
|
||||
typedef union {
|
||||
struct
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
uint8_t version_length; // 3 bit - Protocol version
|
||||
// 5 bit - Length of payload
|
||||
@@ -167,6 +177,12 @@ public:
|
||||
int iValue;
|
||||
char data[MAX_PAYLOAD + 1];
|
||||
} __attribute__((packed));
|
||||
#ifdef __cplusplus
|
||||
} __attribute__((packed));
|
||||
#else
|
||||
};
|
||||
uint8_t array[HEADER_SIZE + MAX_PAYLOAD + 1];
|
||||
} __attribute__((packed)) MyMessage;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user