GithubHelp home page GithubHelp logo

khoih-prog / wifinina_generic Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 12.0 2.61 MB

Enables WiFiNINA network connection (local and Internet) for SAM DUE, SAMD21, SAMD51, Teensy, AVR Mega, STM32, RP2040-based boards, etc. in addition to Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000, Arduino UNO WiFi Rev.2 , Nano 33 IoT, Nano_RP2040_Connect. Now with fix of severe limitation to permit sending much larger data than total 4K

License: GNU General Public License v3.0

C++ 60.29% C 39.41% Shell 0.30%
wifi-modules wifinina samd21 samd51 stm32 mega2560 sam-due nano-33-iot mkr1000 mkr1010

wifinina_generic's People

Contributors

khoih-prog avatar mouradelbellili avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wifinina_generic's Issues

nRF52840-DK with ATWINC1500 on SES

OS: Ubuntu 20.04 LTS
Linux ad1tya0 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Context:

I'm trying to develop a project where I use a nRF52840 devkit and an ATWINC1500 WiFi module to give it WiFi connectivity. I want to use the WiFiNINA library for the interface, however I'm using Segger Embedded Studio for development and most of the examples I can find here about the board uses Adafruit libraries/Arduino IDE.
Could I get a pointer in the right direction as to where to go with it?

No free space new client / Counting of clients wrong.

Try to setup a web socket server with wifinina.

When I try the example Generic_WebSocketServer_WiFiNINA.ino the
websocket connection is always closed. I try to connect with different clients.
As far I can see the MKR WiFi 1010 should be supported since version 2.1.3.

I try to open only one connection.
It looks for me that the counting of the clients is not correct. See the log.

Wifi-version:
WiFiNINA firmware check.
Firmware version installed: 1.3.0
Latest firmware version available : 1.3.0
Check result: PASSED

websockets generic version: 2.2.2

[WS] 0 new client
[WS] 0 [handleHeader] RX: GET / HTTP/1.1
[WS] 1 new client
[WS] 0 [handleHeader] RX: Host: 10.X.X.X:81
[WS] 1 [handleHeader] RX: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0
[WS] 2 new client
[WS] 0 [handleHeader] RX: Accept: /
[WS] 1 [handleHeader] RX: Accept-Language: de,en-US;q=0.7,en;q=0.3
[WS] 2 [handleHeader] RX: Accept-Encoding: gzip, deflate
[WS] 3 new client
[WS] 0 [handleHeader] RX: Sec-WebSocket-Version: 13
[WS] 1 [handleHeader] RX: Origin: moz-extension://79922fef-6785-6549-9f19-3efc822c7d29
[WS] 2 [handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS] 3 [handleHeader] RX: Sec-WebSocket-Extensions: permessage-deflate
[WS] 4 new client
[WS] 0 [handleHeader] RX: Sec-WebSocket-Key: 3yzKvswNEXx9sBqgHUK7qw==
[WS] 1 [handleHeader] RX: Connection: keep-alive, Upgrade
[WS] 2 [handleHeader] RX: Pragma: no-cache
[WS] 3 [handleHeader] RX: Cache-Control: no-cache
[WS] 4 [handleHeader] RX: Upgrade: websocket
[WS] [WS-Server] No free space new client
[WS] 0 client connection lost
[WS] 0 client disconnected.

WiFiNiNa generic STM32F446RE with AirLift WiFi ESP32 co-processor - doesn't communicate

Hello, thank you for work with library.
I try to connect to wifi by using Airlift ESP32 which controls by STM32F446RE. I done requirements in changing pinout, but whatever I done I always receive this in serial port.

15:26:34.947 -> Start ScanNetworks on NUCLEO_F446RE
15:26:34.947 -> Version 1.7.2
15:26:35.701 -> Communication with WiFi module failed!

I am not sure what do wrong.
P.S. I try not my code but example.

NTP request results in "ServerDrv::availData: SpiDrv not available"

NOTE: "insert code" does not work in this editor, I used it but to no avail...

Describe the bug

When using NOT using delay() I get the "ServerDrv::availData: SpiDrv not available" error

Steps to Reproduce

NOT use delay() after an NTP Udp request...

Expected behavior

no error?

Actual behavior

"ServerDrv::availData: SpiDrv not available" error

Debug and AT-command log (if applicable)

Serial monitor output:

11:52:13.132 -> 10:52:13 15.10.2021
11:52:14.127 -> 10:52:14 15.10.2021
11:52:15.121 -> 10:52:15 15.10.2021
11:52:16.116 -> 10:52:16 15.10.2021
11:52:17.144 -> 10:52:17 15.10.2021
11:52:18.138 -> 10:52:18 15.10.2021
11:52:19.133 -> 10:52:19 15.10.2021
11:52:20.127 -> 10:52:20 15.10.2021
11:52:21.121 -> 10:52:21 15.10.2021
11:52:22.149 -> 10:52:22 15.10.2021
11:52:23.143 -> ServerDrv::availData: SpiDrv not available
11:52:23.143 -> Transmit NTP Request
11:52:23.143 -> us.pool.ntp.org: 165.227.219.198
11:52:23.143 -> ServerDrv::availData: SpiDrv not available
11:52:23.143 -> ServerDrv::availData: SpiDrv not available
11:52:23.143 -> ServerDrv::availData: SpiDrv not available
11:52:23.143 -> ServerDrv::availData: SpiDrv not available
.
.<cut a lot of lines>
.
11:52:23.275 -> ServerDrv::availData: SpiDrv not available
11:52:23.275 -> ServerDrv::availData: SpiDrv not available
11:52:23.275 -> ServerDrv::availData: SpiDrv not available
11:52:23.275 -> Receive NTP Response
11:52:23.275 -> 10:52:23 15.10.2021   <<< 15 seconds no NTP sync!
11:52:24.270 -> 10:52:24 15.10.2021
11:52:25.264 -> 10:52:25 15.10.2021
11:52:26.259 -> 10:52:26 15.10.2021
11:52:27.287 -> 10:52:27 15.10.2021
11:52:28.281 -> 10:52:28 15.10.2021
11:52:29.276 -> 10:52:29 15.10.2021 
11:52:30.271 -> 10:52:30 15.10.2021
11:52:31.265 -> 10:52:31 15.10.2021
11:52:32.260 -> 10:52:32 15.10.2021
11:52:33.288 -> 10:52:33 15.10.2021
11:52:34.282 -> 10:52:34 15.10.2021
11:52:35.277 -> 10:52:35 15.10.2021
11:52:36.271 -> 10:52:36 15.10.2021
11:52:37.266 -> 10:52:37 15.10.2021
11:52:38.261 -> ServerDrv::availData: SpiDrv not available
11:52:38.261 -> Transmit NTP Request
11:52:38.261 -> us.pool.ntp.org: 165.227.219.198
11:52:38.261 -> ServerDrv::availData: SpiDrv not available
11:52:38.261 -> ServerDrv::availData: SpiDrv not available
etc.etc.

Screenshots

If applicable, add screenshots to help explain your problem.

Information

Please ensure to specify the following:

Arduino IDE version 1.8.16
Arduino nano 33 IoT SAMD21 board

Example

sketch to reproduce:

//
// sketch from examples of library "*Time* by *Michael Margolis*"
// LATEST version
// adapted to use with WifiNINA library LATEST VERSION


#include <TimeLib.h>
#include <SPI.h>
#include <WiFiNINA_Generic.h>
#include <WiFiUdp_Generic.h>

const char ssid[] = "**********";      //  your network SSID (name)
const char pass[] = "**********";  // your network password

// NTP Servers:
static const char ntpServerName[] = "us.pool.ntp.org";
//static const char ntpServerName[] = "time.nist.gov";
//static const char ntpServerName[] = "time-a.timefreq.bldrdoc.gov";
//static const char ntpServerName[] = "time-b.timefreq.bldrdoc.gov";
//static const char ntpServerName[] = "time-c.timefreq.bldrdoc.gov";

const int timeZone = 1;     // Central European Time
//const int timeZone = -5;  // Eastern Standard Time (USA)
//const int timeZone = -4;  // Eastern Daylight Time (USA)
//const int timeZone = -8;  // Pacific Standard Time (USA)
//const int timeZone = -7;  // Pacific Daylight Time (USA)


WiFiUDP Udp;
unsigned int localPort = 8888;  // local port to listen for UDP packets

time_t getNtpTime();
void digitalClockDisplay();
void printDigits(int digits);
void sendNTPpacket(IPAddress &address);

void setup()
{
  Serial.begin(115200);
  while (!Serial) ; // Needed for Leonardo only
  delay(250);
  Serial.println("TimeNTP Example");
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);

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

  Serial.print("IP number assigned by DHCP is ");
  Serial.println(WiFi.localIP());
  Serial.println("Starting UDP");
  Udp.begin(localPort);
  //Serial.print("Local port: ");
  //Serial.println(Udp.localPort());
  Serial.println("waiting for sync");
  setSyncProvider(getNtpTime);
  setSyncInterval(15);
}

time_t prevDisplay = 0; // when the digital clock was displayed

void loop()
{
  if (timeStatus() != timeNotSet) {
    if (now() != prevDisplay) { //update the display only if time has changed
      prevDisplay = now();
      digitalClockDisplay();
    }
  }
}

void digitalClockDisplay()
{
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(".");
  Serial.print(month());
  Serial.print(".");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits)
{
  // utility for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

/*-------- NTP code ----------*/

const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message
byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets

time_t getNtpTime()
{
  IPAddress ntpServerIP; // NTP server's ip address

  while (Udp.parsePacket() > 0) ; // discard any previously received packets
  Serial.println("Transmit NTP Request");
  // get a random server from the pool
  WiFi.hostByName(ntpServerName, ntpServerIP);
  Serial.print(ntpServerName);
  Serial.print(": ");
  Serial.println(ntpServerIP);
  sendNTPpacket(ntpServerIP);
  uint32_t beginWait = millis();
  while (millis() - beginWait < 1500) {
    int size = Udp.parsePacket();
    if (size >= NTP_PACKET_SIZE) {
      Serial.println("Receive NTP Response");
      Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer
      unsigned long secsSince1900;
      // convert four bytes starting at location 40 to a long integer
      secsSince1900 =  (unsigned long)packetBuffer[40] << 24;
      secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
      secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
      secsSince1900 |= (unsigned long)packetBuffer[43];
      return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;
    }
  }
  Serial.println("No NTP Response :-(");
  return 0; // return 0 if unable to get the time
}

// send an NTP request to the time server at the given address
void sendNTPpacket(IPAddress &address)
{
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE);
  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)
  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  // 8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12] = 49;
  packetBuffer[13] = 0x4E;
  packetBuffer[14] = 49;
  packetBuffer[15] = 52;
  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:
  Udp.beginPacket(address, 123); //NTP requests are to port 123
  Udp.write(packetBuffer, NTP_PACKET_SIZE);
  Udp.endPacket();
}

Wio Terminal can't communicate with module error

Hi, I'm getting the following error when trying to run any of the examples:

Start WiFiNINA CheckFirmwareVersion on SAMD SEEED_WIO_TERMINAL
WiFiNINA_Generic v1.8.13
Communication with WiFi module failed!

I have flashed the latest firmware for the RTL8720 chip (2.1.3) could that be the problem?

Invalid license?

Thanks for your work on this library (and others!).

Background

Per this library's README:

This library is based on and modified from Arduino WiFiNINA library

Problem

The WiFiNINA library for Arduino is released under the GNU LGPL v2.1 or later, but this WiFiNINA_Generic library says it is released under the more permissive MIT license. As I understand it, this is not allowed for a derivative work, unless you've gotten permission from the copyright holder(s) of the original work.

Solutions

I believe the easiest compliant solution would be to release WiFiNINA_Generic under LGPL v2.1 (and/or a later version). Alternatively, I think you'd need to get permission from the original work's copyright holder(s) to release it under a more permissive license (MIT, or whatever else you all agree to).

Undesired prints (`ServerDrv::availData: SpiDrv not available`) appear in console when using the library

Describe the bug

server_drv.cpp contains debug macros which cause undesired serial prints

#define _DEBUG_

#define KH_WIFININA_SERVER_DRV_DEBUG   1

And usage:

uint16_t ServerDrv::availData(uint8_t sock)
{
  if  (!SpiDrv::available()) 
  {
    // KH
#if (KH_WIFININA_SERVER_DRV_DEBUG > 0)
    Serial.println("ServerDrv::availData: SpiDrv not available");
#endif    
    return 0;
  }
 
  // KH
#if (KH_WIFININA_SERVER_DRV_DEBUG > 2)    
  Serial.println("ServerDrv::availData: SpiDrv OK");
#endif  

  WAIT_FOR_SLAVE_SELECT();
  // Send Command
  SpiDrv::sendCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1);
  SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);

  // pad to multiple of 4
  SpiDrv::readChar();
  SpiDrv::readChar();

  SpiDrv::spiSlaveDeselect();
  //Wait the reply elaboration
  SpiDrv::waitForSlaveReady();
  SpiDrv::spiSlaveSelect();

  // Wait for reply
  uint8_t _dataLen = 0;
  uint16_t len = 0;

  SpiDrv::waitResponseCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1, (uint8_t*)&len,  &_dataLen);

  SpiDrv::spiSlaveDeselect();
  
  // KH
#if (KH_WIFININA_SERVER_DRV_DEBUG > 2)
  Serial.print("ServerDrv::availData: len =");
  Serial.println(len);
#endif

  return len;
}

NRF52840-DK

Greetings!

Can it be used with nrf52840dk?

Thank you in advance!

u-blox nina b

@khoih-prog

Hi

Is it possible to port to NRF52 chips ? I can test here!

Are the routines HIGH level ? (hardware gpios access)

Thanks!

Storage class

Hello,
Your library is great, but the storage part does not work, The original WiFinina does.
It looks something related to the WiFi_Drv class.

C:\Users\vdavi\AppData\Local\Temp\arduino_build_453956\sketch\Server.ino.cpp.o: In function setup':

C:\Users\vdavi\Documents\Arduino\libraries\WiFiNINA_Generic\src/utility/wifi_drv.h:344: undefined reference to `WiFiDrv::fileOperation(unsigned char, char const*, unsigned char, unsigned long, unsigned char*, unsigned long)'

C:\Users\vdavi\Documents\Arduino\libraries\WiFiNINA_Generic\src/utility/wifi_drv.h:337: undefined reference to `WiFiDrv::fileOperation(unsigned char, char const*, unsigned char, unsigned long, unsigned char*, unsigned long)'

C:\Users\vdavi\AppData\Local\Temp\arduino_build_453956\libraries\WiFiNINA_Generic\WiFiStorage_Generic.cpp.o: In function `WiFiStorageClass::exists(char const*, unsigned long*)':

C:\Users\vdavi\Documents\Arduino\libraries\WiFiNINA_Generic\src\utility/wifi_drv.h:344: undefined reference to `WiFiDrv::fileOperation(unsigned char, char const*, unsigned char, unsigned long, unsigned char*, unsigned long)'

collect2.exe: error: ld returned 1 exit status`

Maybe you could have a look into that.
Thanks a lot

Davide

Arduino nano 33 ble compatibility with a NINA W10 co-processor?

Hi,
I'm currently trying to make the Adafruit ItsyBitsy Esp32 co-processor add-on work with the arduino Nano 33 BLE.

I tried using the Adafruit WifiNINA and the WifiNINA_generic libraries. At first the examples weren't compiling, however, by adding the "arduino::" prefix to each call of the IPAddress, UDP and Print classes in the WifiUdp.h file, I managed to make it compile.
This being done, I thought it would work but no, I get the message "Communication with WiFi module failed!". I checked my wiring a hundred times, nothing changes.
I tried making it work with the MKR 1310 board (SAMD21 processor) and I succeded.

I guess that what's causing trouble is the fact that the Nano 33 BLE is based on MBED OS and is not fully supporting every arduino features. However, I was wondering if someone had any infos on how to make it work.

Thanks in advance,
Colas LEPOUTRE

Pinout for STM32F1 "blue pill"

Hi,

I have an issue with communicating with my "Adafruit atwinc1500 breakout board".
Its connected to a Blue Pill (STM32F103C8T6), using Arduino IDE 1.8.3 and Arduino Core 1.9.0
Pins:
MISO,MOSI,SCK (PA7,PA6,PA5)
PA4 - CS
PA3 - IRQ
PA2 - Reset
But I cannot communicate with the board.
I´m a little puzzled with the pinout found in the "Wifinina_pinout_generic.h" file.

Any help is very appreciated!

UPDATE, I can load the official WiFi101 library and I´m able to print out the firmware version using one of the examples, but I cannot run anything else. This would at least tell me the wiring is correct. But running the same "CheckFirmwareVersion" in WiFiNINA Generic does not work.

Fix server.send buffer size limited to 4k

Created by @jlemieux55 as server.send buffer size limited to 4k #23

html file or message is > 4500 bytes
server.send buffer truncates at > 4096
String message="";
message+=("html content is over 4500 bytes");
server.send(200, "text/html", message);

Platform: Arduino MKR1010 (wifinina)

Closed via WiFiNINA_Generic v1.8.15-0 which permits sending much larger data than total 4K.


Releases v1.8.15-0

  1. Fix severe limitation to permit sending much larger data than total 4K. Check server.send buffer size limited to 4k #23
  2. Add examples WiFiWebServer_BigData to demo how to send much larger data than total 4K
  3. Optimize code
  4. Clean up

Debug Terminal

The following is debug terminal output when running example WiFiWebServer_BigData on NANO_RP2040_CONNECT board, using this WiFiNINA_Generic Library, to demo how to send much larger data than total 4K

Start WiFiWebServer_BigData on NANO_RP2040_CONNECT
WiFiNINA_Generic v1.8.15-0
WiFiWebServer v1.10.0
Attempting to connect to SSID: HueNet
Attempting to connect to SSID: HueNet
SSID: HueNet
IP Address: 192.168.2.117
Signal strength (RSSI):-24 dBm
String Len = 27609
String Len = 27609

Issues with platformIO project getting error Communication with WiFi module failed!

Describe the bug

I have a custom board based on the sparkfun_samd51_micromod that has a Ublox W102 attached to it. I'm able to use the WiFiNINA from Arduino and Adafruit WiFiNINA Library by only changing the corresponding pins. However, I would like to use the WiFiManager_NINA_Lite in my project so I tried to use the WiFiNINA_Generic but I get Communication with WiFi Module error. So I tried with one of the supported boards in my case the Arduino MKR1010 and I get the same error which makes me think that something in my PlatformIO project is not set correctly.

Steps to Reproduce

Create a new project using PlatformIO Core 6.0.2·Home 3.4.2
for board select mkrwifi1010
frame work arduino.
install WiFiNINA_Generic using the Library registry.
copy the patch https://raw.githubusercontent.com/khoih-prog/WiFiNINA_Generic/master/Packages_Patches/arduino/hardware/samd/1.8.13/platform.txt

into C:\xxxx\xxxx.platformio\packages\framework-arduino-samd\

The plarformio.ini file should look like this

[env:mkrwifi1010]
platform = atmelsam
board = mkrwifi1010
framework = arduino
lib_deps = khoih-prog/WiFiNINA_Generic@^1.8.14-5

copy the content of WiFiping.ino into the main.cpp and move the .h files to the lib folder

Expected behavior

I would expect the board to connect to the local wiifi and ping google.com

Actual behavior

For the Arduino MKR1010 I get
Serial console prints

Start WiFiPing on SAMD MKRWIFI1010
WiFiNINA_Generic v1.8.14-5        
Communication with WiFi module failed!

Information

Please ensure to specify the following:

  • Platform.io version Core 6.0.2·Home 3.4.2
  • `Arduino MKR1010 samd21 and SAMD51
  • I'm hoping to use the WiFiManager_NINA_Lite in my project so I'm hoping to use the WiFiNINA_Generic

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.