Compare commits

..

No commits in common. "72851b69c556ccd0380ebe9a153ecbad508b1110" and "19b099270a5e71df8e23267074b9f329b2fd0e6d" have entirely different histories.

3 changed files with 20 additions and 50 deletions

View File

@ -7,16 +7,8 @@ export:
buildIdf:
idf.py build
flash0:
sudo chmod o+rw /dev/ttyUSB0
flash:
idf.py flash -p /dev/ttyUSB0
flash1:
sudo chmod o+rw /dev/ttyUSB1
idf.py flash -p /dev/ttyUSB1
monitor0:
idf.py monitor -p /dev/ttyUSB0
monitor1:
idf.py monitor -p /dev/ttyUSB1
monitor:
idf.py monitor

View File

@ -26,7 +26,7 @@
#define CONFIG_ESPNOW_PMK "pmk1234567890123"
#define CONFIG_ESPNOW_SEND_COUNT 100
#define CONFIG_ESPNOW_SEND_DELAY 1000
#define CONFIG_ESPNOW_SEND_LEN 250
#define CONFIG_ESPNOW_SEND_LEN 10
#define CONFIG_ESPNOW_LMK "lmk1234567890123"
const char *tag = "Exam";
@ -70,8 +70,6 @@ static void example_espnow_deinit(example_espnow_send_param_t *send_param) {
void example_espnow_data_prepare(example_espnow_send_param_t *send_param) {
example_espnow_data_t *buf = (example_espnow_data_t *)send_param->buffer;
ESP_LOGI(tag, "Example_Data_SIZE: %u, send_param_len: %d\n", sizeof(example_espnow_data_t), send_param->len);
assert(send_param->len >= sizeof(example_espnow_data_t));
buf->type = IS_BROADCAST_ADDR(send_param->dest_mac)
@ -81,11 +79,9 @@ void example_espnow_data_prepare(example_espnow_send_param_t *send_param) {
buf->seq_num = s_example_espnow_seq[buf->type]++;
buf->crc = 0;
buf->magic = send_param->magic;
buf->payload.isMaster = isMaster;
/* Fill all remaining bytes after the data with random values */
/* esp_fill_random(buf->payload,
send_param->len - sizeof(example_espnow_data_t)); */ // wieso sollte ich das mit random daten füllen
esp_fill_random(buf->payload,
send_param->len - sizeof(example_espnow_data_t));
buf->crc = esp_crc16_le(UINT16_MAX, (uint8_t const *)buf, send_param->len);
}
@ -161,12 +157,6 @@ int example_espnow_data_parse(uint8_t *data, uint16_t data_len, uint8_t *state,
buf->crc = 0;
crc_cal = esp_crc16_le(UINT16_MAX, (uint8_t const *)buf, data_len);
if(buf->payload.isMaster) {
ESP_LOGE(tag, "Recived Data from Master");
} else {
ESP_LOGE(tag, "Recived Data from Slave");
}
if (crc_cal == crc) {
return buf->type;
}
@ -389,7 +379,6 @@ static esp_err_t example_espnow_init(void) {
}
void app_main(void) {
// Master Slave Detection, default pin is pull up so ground it and check state
gpio_reset_pin(Master_SlavePin);
gpio_set_direction(Master_SlavePin, GPIO_MODE_INPUT);
int checkMaster = gpio_get_level(Master_SlavePin);

View File

@ -2,11 +2,9 @@
#define MAIN_H
#define Master_SlavePin 23
#define MAX_PAYLOAD_SIZE 250
#define ESPNOW_QUEUE_SIZE 6
#define IS_BROADCAST_ADDR(addr) \
(memcmp(addr, s_example_broadcast_mac, ESP_NOW_ETH_ALEN) == 0)
#define IS_BROADCAST_ADDR(addr) (memcmp(addr, s_example_broadcast_mac, ESP_NOW_ETH_ALEN) == 0)
static bool isMaster;
@ -41,23 +39,14 @@ enum {
EXAMPLE_ESPNOW_DATA_UNICAST,
EXAMPLE_ESPNOW_DATA_MAX,
};
typedef struct {
bool isMaster;
} __attribute__((packed)) payloadData;
static_assert(sizeof(payloadData) <= MAX_PAYLOAD_SIZE, "payloadData struct is too big to be sent in one part, keep it under 250 Bytes!");
/* User defined field of ESPNOW data in this example. */
typedef struct {
uint8_t type; // Broadcast or unicast ESPNOW data.
uint8_t state; // Indicate that if has received broadcast ESPNOW data or not.
uint16_t seq_num; // Sequence number of ESPNOW data.
uint16_t crc; // CRC16 value of ESPNOW data.
uint32_t magic; // Magic number which is used to determine which device to
// send unicast ESPNOW data.
payloadData payload; // Real payload of ESPNOW data.
uint8_t type; //Broadcast or unicast ESPNOW data.
uint8_t state; //Indicate that if has received broadcast ESPNOW data or not.
uint16_t seq_num; //Sequence number of ESPNOW data.
uint16_t crc; //CRC16 value of ESPNOW data.
uint32_t magic; //Magic number which is used to determine which device to send unicast ESPNOW data.
uint8_t payload[0]; //Real payload of ESPNOW data.
} __attribute__((packed)) example_espnow_data_t;
typedef struct {