从.ino到.h请求数据,在我的.h下有二进制需要转换它

Requesting data from .ino to .h where under my .h has on binary need to convert it

提问人:Michael Guablas 提问时间:11/10/2023 更新时间:11/10/2023 访问量:15

问:

您好,你们能帮我吗,我尝试实现 AJAX 或 webSocket,但当我更改某些东西时,相机停止运行,我惨遭失败,我只想让我的 esp32 Web 服务器在视频流下显示来自串行硬件的串行数据,这是我的 .ino 中的代码

#include <Arduino.h>
#include "esp_camera.h"
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>

HardwareSerial UNOSerial(2);

String serialData = "";
String displayedData = "";  

#define CAMERA_MODEL_AI_THINKER // Has PSRAM

#include "camera_pins.h"

// ===========================
// Enter your WiFi credentials
// ===========================
const char* ssid     = "LLLLLLLLLLLLLL";
const char* password = "59615330";
// Set your Static IP address
IPAddress local_IP(192, 168, 1, 150);
// Set your Gateway IP address
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 254, 0);

void startCameraServer();
void setupLedFlash(int pin);

void setup() {

  Serial.begin(115200);
  UNOSerial.begin(115200, SERIAL_8N1, 12, 13);

  if (!WiFi.config(local_IP, gateway, subnet)) {
    Serial.println("STA Failed to configure");
  }
  WiFi.begin(ssid, password);
  Serial.setDebugOutput(true);
  Serial.println();

  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sccb_sda = SIOD_GPIO_NUM;
  config.pin_sccb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.frame_size = FRAMESIZE_HD; // Set to HD resolution
  config.pixel_format = PIXFORMAT_JPEG; // for streaming
  config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
  config.fb_location = CAMERA_FB_IN_PSRAM;
  config.jpeg_quality = 14;
  config.fb_count = 1;


  // if PSRAM IC is present, init with HD resolution and higher JPEG quality
  // for a larger pre-allocated frame buffer.
  if (config.pixel_format == PIXFORMAT_JPEG) {
    if (psramFound()) {
      config.jpeg_quality = 10;
      config.fb_count = 2;
      config.grab_mode = CAMERA_GRAB_LATEST;
    } else {
      // Limit the frame size when PSRAM is not available
      config.frame_size = FRAMESIZE_VGA; // Set to VGA resolution
      config.fb_location = CAMERA_FB_IN_DRAM;
    }
  } else {
    // Best option for face detection/recognition
    config.frame_size = FRAMESIZE_VGA; // Set to VGA resolution
    config.fb_count = 2;
  }

#if defined(CAMERA_MODEL_ESP_EYE)
  pinMode(13, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
#endif

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  sensor_t *s = esp_camera_sensor_get();
  // Initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1); // Flip it back
    s->set_brightness(s, 1); // Increase the brightness just a bit
    s->set_saturation(s, -2); // Decrease the saturation
  }

  // Setup LED Flash if LED pin is defined in camera_pins.h
#if defined(LED_GPIO_NUM)
  setupLedFlash(LED_GPIO_NUM);
#endif

  WiFi.begin(ssid, password);
  WiFi.setSleep(false);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  startCameraServer();

  Serial.print("Camera Ready! Use 'http://");
  Serial.print(WiFi.localIP());
  Serial.println("' to connect");
}

void loop() {
  while (UNOSerial.available()) {
    char c = UNOSerial.read();
    Serial.write(c);  // Echo the data to the main Serial
    serialData += c;  // Append the received data to the serialData variable

  // You can add the code to send the received data to the web server here
}
}

我的 .h 在不同的源代码上,代码在二进制上,我需要将其转换为 gzip #define index_ov5640_html_gz_len 9458

Ajax WebSocket Arduino

评论


答: 暂无答案