Arduino Forum

Products => Arduino Zero => Topic started by: x-giorgio-x on Oct 09, 2018, 03:26 pm

Title: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 09, 2018, 03:26 pm
Hi

Is there an Arduino library, for ESP with at commands, compatible with the WiFi library ?
Or a good library ?
For zero.

WiFi class:
begin()
disconnect()
config()
setDNS()
SSID()
BSSID()
RSSI()
encryptionType()
scanNetworks()
status()
getSocket()
macAddress()
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: Juraj on Oct 09, 2018, 03:46 pm
there is only one such library for AT commands - WiFiEsp. but it is not made to be compatible with SAMD architecture

for example Teensy SAMD board users connect esp8266 over SPI and use WiFiSpiESP firmware and library. it is easier then with 5 V AVR boards because both boards are 3.3V, no level shifting is needed.

https://github.com/JiriBilek/WiFiSpiESP
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 09, 2018, 05:19 pm
This use SPI.
I need use UART RX and Tx and AT command.
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: pert on Oct 09, 2018, 05:49 pm
What is SAMD-incompatible about the WiFiEsp library? I haven't dug into the source very deeply but I can't imagine any of the code being architecture specific. The library.properties metadata claims it's compatible with all architectures.
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 09, 2018, 06:33 pm
Code: [Select]

Arduino: 1.8.5 (Windows 10), Board: "GEVINO SAM-BA bootloader"

C:\Users\x-gio\Documents\Arduino\libraries\WiFiEsp\src\utility\EspDrv.cpp: In static member function 'static int EspDrv::sendCmd(const __FlashStringHelper*, int, ...)':

C:\Users\x-gio\Documents\Arduino\libraries\WiFiEsp\src\utility\EspDrv.cpp:1020:25: error: 'va_start' was not declared in this scope

  va_start (args, timeout);

                         ^

C:\Users\x-gio\Documents\Arduino\libraries\WiFiEsp\src\utility\EspDrv.cpp:1021:56: error: 'vsnprintf_P' was not declared in this scope

  vsnprintf_P (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);

                                                        ^

C:\Users\x-gio\Documents\Arduino\libraries\WiFiEsp\src\utility\EspDrv.cpp:1022:21: error: '__gnuc_va_end' was not declared in this scope

  __gnuc_va_end (args);

                     ^

exit status 1
Error compiling for board GEVINO SAM-BA bootloader.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: Juraj on Oct 09, 2018, 07:09 pm
What is SAMD-incompatible about the WiFiEsp library? I haven't dug into the source very deeply but I can't imagine any of the code being architecture specific. The library.properties metadata claims it's compatible with all architectures.
RingBuffer exists in SAMD core and in WiFiEsp and implementation of functions with variable arguments length are not compatible with ARM compiler
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: pert on Oct 09, 2018, 07:24 pm
RingBuffer exists in SAMD core and in WiFiEsp
Since WiFiEsp uses the correct #include syntax, I don't see anything that would be problematic about that at a glance.

implementation of functions with variable arguments length are not compatible with ARM compiler
I noticed that from the error messages in the previous reply. I guess that needs C++11? It should be resolved by:
https://github.com/arduino/ArduinoCore-samd/issues/313 (https://github.com/arduino/ArduinoCore-samd/issues/313)
but there doesn't seem to be recent progress on that. It's kind of funny that the relatively modern SAMD boards are using a more outdated toolchain than the old school AVR.
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: Juraj on Oct 09, 2018, 07:35 pm
Since WiFiEsp uses the correct #include syntax, I don't see anything that would be problematic about that at a glance.

RingBuffer in SAMD core is a template class
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 10, 2018, 08:26 am
I have solved all the compilation issues this way, but it seems to not Work.

Changed RingBuff Class on RingBuffW
Added
#include <stdarg.h>
#include <stdio.h>
Changed
vsnprintf_P (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);
with
vsnprintf (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);

How is the equivalent of Vsnprintf_P with ARM ?
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: Juraj on Oct 10, 2018, 09:00 am
I have solved all the compilation issues this way, but it seems to not Work.

Changed RingBuff Class on RingBuffW
Added
#include <stdarg.h>
#include <stdio.h>
Changed
vsnprintf_P (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);
with
vsnprintf (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);

How is the equivalent of Vsnprintf_P with ARM ?
ARM doesn't have PROGMEM, so no _P functions. use the version without _P
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 10, 2018, 10:38 am
This exactly my change.

Changed on RingBuffer.cpp & RingBuffer.h & EspDrv.cpp & EspDrv.h & Scketh
   RingBuff Class on RingBuffW
Added on EspDrv.cpp
   #include <stdarg.h>
Changed on EspDrv.cpp
   vsnprintf_P (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);
with
   vsnprintf (cmdBuf, CMD_BUFFER_SIZE, (char*)cmd, args);


But unit reboot each fiew seconds.
ESP led, blink repeatedly every few seconds, USB driver disappears and Returns.
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: Juraj on Oct 10, 2018, 10:40 am
I hope you use Serial1 for esp8266, not the SerialUSB?
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 10, 2018, 11:30 am
Yes, I use Serial for ESP, SerialUSB for debug.



Code: [Select]

// use a ring buffer to increase speed and reduce memory allocation
RingBufferW buf(8);

void setup()
{
  Serial.begin(115200);       // initialize serial for ESP module
  SerialUSB.begin(115200);    // initialize serial for debugging
  WiFi.init(&Serial);         // initialize ESP module
Title: Re: Is there an Arduino library, for ESP with at commands ?
Post by: x-giorgio-x on Oct 10, 2018, 12:35 pm
Ok, no, all Work Well.

Only small problem.
On USB debug Appears IP 0.0.0.0
But really work well at 192.168.1.1