remove example proj. bye2

This commit is contained in:
Dooho Yi 2021-02-18 21:59:41 +09:00
parent 42a96a435a
commit 591888b611
2 changed files with 0 additions and 138 deletions

View file

@ -1,43 +0,0 @@
; < NOTE >
; to enable verbose output add option -->
; $ platformio run --verbose
; to make this permanent for the proj. -->
; $ platformio settings set force_verbose Yes
; then confirm the change -->
; $ platformio settings get
; // pio v 4.0 'Build options'
; - build_type
; - build_flags
; - src_build_flags
; - build_unflags
; - src_filter
; - targets
[platformio]
default_envs = d1_mini_pro
[env]
framework = arduino
upload_speed = 460800
upload_port = /dev/ttyUSB0
lib_deps =
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
lib_deps =
${env.lib_deps}
[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
upload_speed = 460800
; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
lib_deps =
${env.lib_deps}

View file

@ -1,95 +0,0 @@
// we want to first osc -> esp-now
// then, esp-now based taak
// then, let is save a value in EEPROM (object with memory)
// no broadcast for now. if needed we can achieve that too.
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <espnow.h>
//uint8_t broadcastAddress[] = {0xF4, 0xCF, 0xA2, 0xED, 0xB3, 0xC5};
uint8_t broadcastAddress[] = {0xF4, 0xCF, 0xA2, 0xED, 0xB7, 0x21};
typedef struct struct_message {
char a[32];
int b;
float c;
String d;
bool e;
} struct_message;
struct_message myData;
unsigned long lastTime = 0;
unsigned long timerDelay = 20; // send readings timer
// Callback when data is sent
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
Serial.print("Last Packet Send Status: ");
if (sendStatus == 0) {
Serial.println("Delivery success");
}
else{
Serial.println("Delivery fail");
}
}
// Callback function that will be executed when data is received
void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
memcpy(&myData, incomingData, sizeof(myData));
Serial.print("Bytes received: ");
Serial.println(len);
Serial.print("Char: ");
Serial.println(myData.a);
Serial.print("Int: ");
Serial.println(myData.b);
Serial.print("Float: ");
Serial.println(myData.c);
Serial.print("String: ");
Serial.println(myData.d);
Serial.print("Bool: ");
Serial.println(myData.e);
Serial.println();
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.print("ESP8266 Board MAC Address: ");
Serial.println(WiFi.macAddress());
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
}
// Once ESPNow is successfully Init, we will register for Send CB to
// get the status of Trasnmitted packet
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
esp_now_register_send_cb(OnDataSent);
esp_now_register_recv_cb(OnDataRecv);
// Register peer
esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
}
void loop() {
if ((millis() - lastTime) > timerDelay) {
static int count = 0;
count++;
// Set values to send
strcpy(myData.a, "THIS IS A CHAR");
myData.b = count;
myData.c = 1.2;
myData.d = "Hello";
myData.e = false;
// Send message via ESP-NOW
esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
lastTime = millis();
}
}