clean up apple.h

This commit is contained in:
user 2024-10-13 21:43:41 +02:00
parent cb9a85a9e8
commit 5a1672ed41

View file

@ -1,3 +1,4 @@
#include "apple.h"
#include "esp_log.h" #include "esp_log.h"
#include <stdio.h> #include <stdio.h>
@ -8,61 +9,35 @@
#include <esp_wifi.h> #include <esp_wifi.h>
#include <FreeRTOSConfig.h> #include <FreeRTOSConfig.h>
struct appldata;
float getTemp(); float getTemp();
int getUpTime(); int getUpTime();
void getmac(); void getmac();
struct appldata{ struct appldata{
uint8_t mac; uint8_t mac[6];
float temp; float temp;
float battaryVoltage; float battaryVoltage;
int upTime; int upTime;
}; };
struct appldata app_main() { int app_main() {
//tiem delay //tiem delay
vTaskDelay(5000 / portTICK_PERIOD_MS);
//creat var vor mac addres
uint8_t baseMac[6] = {0};
getmac(baseMac,6);
//fill struct //fill struct
struct appldata send; struct appldata send;
send.mac = baseMac ; getmac(send.mac) ;
send.upTime = getUpTime(); send.upTime = getUpTime();
send.temp = getTemp(); send.temp = getTemp();
send.battaryVoltage = 3.3; send.battaryVoltage = 3.3;
//print mac
printf("Station MAC: ");
for (int i = 0; i < 5; i++) {
printf("%02X:", (baseMac[i]));
}
printf("%02X\n", baseMac[5]);
//print uptime
int uptime = getUpTime();
printf("%d", uptime);
//print temp
float temp = getTemp();
printf("Temperature = %.4f\n", temp);
//end func //end func
return send; return 0;
} }
void getmac(uint8_t *buf){
void getmac(uint8_t *buf, int count){
for(int i = 0; i < count; ++i)
buf[i] = i;
// Get MAC address of the WiFi station interface // Get MAC address of the WiFi station interface
esp_read_mac(buf, ESP_MAC_WIFI_STA); esp_read_mac(buf, ESP_MAC_WIFI_STA);
} }