我尝试在 esp32 上运行我的代码后得到了这个
注意:未定义索引:第 23 行 C:\xampp\htdocs\acc.php 中的 imageFile
我在 esp32 上的代码
HTTPClient http;
http.begin("http://192.168.43.86/acc.php"); //Specify destination for HTTP request
http.addHeader("Content-Disposition", "form-data; name=\"imageFile\"; filename=\"picture.jpg\"\r\n");
http.addHeader("Content-type", "image/jpeg");
int httpResponseCode = http.POST(cam.getfb(), cam.getSize());
if (httpResponseCode > 0) {
String response = http.getString(); //Get the response to the request
Serial.println(httpResponseCode); //Print return code
Serial.println(response); //Print request answer
} else {
Serial.print("Error on sending POST: ");
Serial.println(httpResponseCode);
}
http.end();
Run Code Online (Sandbox Code Playgroud)
我可以使用此代码发送字符串,但我上面的代码不起作用(cam.getfb() 返回为 uint8_t,cam.getSize() 返回为 size_t)
http.addHeader("Content-type", "application/x-www-form-urlencoded");
int httpResponseCode = http.POST("word=" + Cword);
Run Code Online (Sandbox Code Playgroud)
php中的代码
<?php …Run Code Online (Sandbox Code Playgroud) 我想将一些文本写入 Arduino ESP32 的闪存中。它有点工作,但不是我想要的。
void writeString(const char* toStore, int startAddr) {
int i = 0;
for (; i < LENGTH(toStore); i++) {
EEPROM.write(startAddr + i, toStore[i]);
}
EEPROM.write(startAddr + i, '\0');
EEPROM.commit();
}
Run Code Online (Sandbox Code Playgroud)
我的电话
writeString("TEST_STRING_TO_WRITE", 0);
Run Code Online (Sandbox Code Playgroud)
只将 TEST 写入内存。我不懂为什么。是因为_吗?或者我错过了一些不同的东西?
这是使用的 LENGTH 宏
#define LENGTH(x) (sizeof(x)/sizeof(x[0]))
Run Code Online (Sandbox Code Playgroud)
以及我用来再次从内存中读取字符串的方法(似乎工作正常):
String readStringFromFlash(int startAddr) {
char in[128];
char curIn;
int i = 0;
curIn = EEPROM.read(startAddr);
for (; i < 128; i++) {
curIn = EEPROM.read(startAddr + i);
in[i] = curIn;
}
return String(in);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试锁定 ESP32。显然,有不同的方法来实现锁:
有默认的 C++ 互斥体库:
#include <mutex>
std::mutex mtx;
mtx.lock();
mtx.unlock();
Run Code Online (Sandbox Code Playgroud)RTOS 的实现如下:
SemaphoreHandle_t xMutex = xSemaphoreCreateMutex();
xSemaphoreTake(xMutex, portMAX_DELAY);
xSemaphoreGive(xMutex);
Run Code Online (Sandbox Code Playgroud)我应该注意哪些根本区别吗?或者说它们是等价的?
我想使用 printf 方法打印我的字符串变量:
\n\n编号 = 6415F1BF713C
\n\n Serial.printf("id: %s\\n\\n", id);\n Serial.print(id);\nRun Code Online (Sandbox Code Playgroud)\n\n我得到的结果是:
\n\nid: \xe2\xb8\xae\xe2\xb8\xae\xe2\xb8\xae?\n6415F1BF713C\nRun Code Online (Sandbox Code Playgroud)\n\n有什么问题吗?
\n\n谢谢。
\n\n更新 :
\n\n//get device id\nString getDeviceID() {\n uint64_t chipid = ESP.getEfuseMac(); // The chip ID is essentially its MAC address(length: 6 bytes).\n uint16_t chip = (uint16_t)(chipid >> 32);\n\n char devID[40];\n snprintf(devID, 40, "%04X%08X", chip, (uint32_t)chipid);\n\n return devID;\n}\nString id = getDeviceID();\n\nSerial.printf("id: %s\\n\\n", id);\nSerial.print(id);\nRun Code Online (Sandbox Code Playgroud)\n 我正在用 ESP32 制作一盏灯,我选择的 HomeKit 库使用我不熟悉的 FreeRTOS 和 esp-idf。
目前,我有一个函数,每当需要更改灯光颜色时就会调用该函数,这只会一步步更改它。我想让它在颜色之间淡入淡出,这需要一个运行一两秒的函数。将此块作为程序的主要执行显然会使其非常无响应,因此我需要将其作为任务运行。
我面临的问题是,我只想一次运行一个淡入淡出函数的副本,如果在完成之前第二次调用它,则第一个副本应该在之前退出(无需等待完整的淡入淡出时间)开始第二个副本。
我发现vTaskDelete,但如果我在任意点终止淡入淡出功能,一些变量和 LED 本身将处于未知状态。为了解决这个问题,我想到使用“kill flag”全局变量,淡入淡出函数将检查其每个循环。
这是我正在考虑的伪代码:
update_light {
kill_flag = true
wait_for_fade_to_die
xTaskCreate fade
}
fade {
kill_flag = false
loop_1000_times {
(fading code involving local and global variables)
.
.
if kill_flag, vTaskDelete(NULL)
vTaskDelay(2 / portTICK_RATE_MS)
}
}
Run Code Online (Sandbox Code Playgroud)
我的主要问题是:
wait_for_fade_to_die?我没有通过简短的浏览找到任何东西,但我是 FreeRTOS 的新手。第一次在这里提问。目前,我在将 ESP32 CAM 拍摄的照片发送到 Android Studio 应用程序时遇到问题。
虽然图片已收到,但大多数时候并不完整,或者显示一些灰色区域,如附图所示。
我注意到可用字节因图片而异,因此我绝望地尝试循环输出/输入流来拍照,直到可用字节超过 14000。仍然有大量可用字节,图片多次(并非总是如此) )显示一大块灰色像素。
我读到这可能是因为蓝牙套接字必须在“最后”异常中关闭,但我无法让它工作。
我非常感谢你的帮助!
private fun tomarFoto() { //Function to take the picture by sending an OutputStream and receiving the taken picture bytes through InputStream
var bytes : ByteArray? = null
val fotoEsp : ImageView = findViewById(R.id.fotoESP)
var available = 0
if (m_bluetoothSocket != null) {
try {
CoroutineScope(IO).launch {
for (i in 0..4) {
async {
m_bluetoothSocket!!.outputStream.write("a".toByteArray())
delay(1500)
}.await()
available = m_bluetoothSocket!!.inputStream.available()
println("Available1: ${available}")
if (available > 14000) {
break …Run Code Online (Sandbox Code Playgroud) 要构建 BLE 应用程序,您需要
举个例子,如果是环境感知服务,我可以从这个页面阅读这个PDF,然后在下面找到,UUID是。然后,我可以去读取相同的PDF和发现(虽然它在文本出于某些原因,它不能被搜索)下,与UUID是。Environmental SensingGATT Service0x181ATemperatureT emperatureTemperatureGATT Characteristic and Object Type0x2A6E
好的,到目前为止一切顺利。然后我撞墙了。要通知的数据大小(例如 uint16_t 或其他)如何或允许哪些权限(例如读/写...)?
经过几个小时的谷歌搜索,我终于找到了这个 github和这个 github。但这不是官方的,有人复制并疏散了他们。
当您没有官方 XML 文件可供查找时,您如何有效地编写 BLE 应用程序?
我最近不得不擦拭我的计算机,在一切准备就绪并运行之后,是时候打开我之前正在处理的一些 ESP32 程序了,发现 VSCode 上的 Platform IO 将不再编译。运行编译器后,我收到以下错误:
Compiling .pio\build\esp32dev\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32dev\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32dev\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32dev\libFrameworkArduino.a
Linking .pio\build\esp32dev\firmware.elf
c:/users/lloyd/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -lstdc++
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32dev\firmware.elf] Error 1
=========================================================================== [FAILED] Took 11.91 seconds ===========================================================================
The terminal process "C:\Users\lloyd\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.
Run Code Online (Sandbox Code Playgroud)
我开始调试并意识到即使使用最简单的程序也无法编译。我尝试了 Arduino IDE,效果很好,还有一些使用 CMaker 的示例,它们也可以正常工作。但是当我尝试上传以下代码时:
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop()
{
// put your main code here, to …Run Code Online (Sandbox Code Playgroud) 我已将 ESP32 注册为 AWS IoT 上的一个事物,并下载了其各自的证书以及公钥和私钥。还通过我的终端中的以下命令验证了这些连接是否正确:
openssl s_client -connect host.iot.region.amazonaws.com:8443 -CAfile AmazonRootCA1.pem -cert certificate.pem.crt -key private.pem.key
Run Code Online (Sandbox Code Playgroud)
这是我的 (main.py) 使用 MicroPython 连接到 AWS IoT 的简单代码
import machine
from network import WLAN
import network
from umqtt.simple import MQTTClient
# AWS endpoint parameters.
HOST = b'HOST' # ex: b'abcdefg1234567'
REGION = b'REGION' # ex: b'us-east-1'
CLIENT_ID = "CLIENT_ID" # Should be unique for each device connected.
AWS_ENDPOINT = b'%s.iot.%s.amazonaws.com' % (HOST, REGION)
keyfile = '/certs/private.pem.key'
with open(keyfile, 'r') as f:
key = f.read() …Run Code Online (Sandbox Code Playgroud) 由 Arduino IDE 执行的 ESP32 flash 命令似乎刷新了两个引导加载程序文件:boot_app0.binat offset0xe000和bootloader_dio_80m.binat offset0x1000。我想知道这两个引导加载程序文件实际上是做什么的,以及为什么有两个。下面我提供一些更多信息。
我所在的团队正在为微控制器开发一种新的免费 IDE:Embeetle IDE。我们计划在不久的将来支持 ESP32 微控制器系列。因此,我现在正在研究 ESP32 构建系统 - 两者ESP-IDF ESP32 项目的工具和 Arduino IDE 方法。
构建.elf文件后,Arduino IDE 会启动一个命令将其转换为二进制文件:
python esptool.py --chip esp32 elf2image
--flash_mode dio
--flash_freq 80m
--flash_size 4MB
-o /tmp/arduino_build_852524/WiFiScan.ino.bin
/tmp/arduino_build_852524/WiFiScan.ino.elf
Run Code Online (Sandbox Code Playgroud)
最后,该WiFiScan.ino.bin文件与两个引导加载程序文件和分区表一起闪存到主板上:
python esptool.py --chip esp32
--port /dev/ttyUSB0
--baud 921600
--before default_reset
--after hard_reset write_flash
-z
--flash_mode dio
--flash_freq 80m
--flash_size detect …Run Code Online (Sandbox Code Playgroud)