B4R Question Problem starting Access Point

janderkan

Well-Known Member
Licensed User
Longtime User
Hi

I have been using Esp8266 for a long time.
Today i found out that it is not possible to start an access point.
I am testing with a wifi-scanner App on my Android phone.
This is the code:
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    Public Serial1 As Serial
    Private wifi As ESP8266WiFi
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log(" ")
    Log("AppStart")
    
    Log(wifi.StartAccessPoint("Futedo"))
End Sub
No access point is showing up.

Then I try this code using Arduino IDE:
C++:
#include <ESP8266WiFi.h>

//////////////////////
// WiFi Definitions //
//////////////////////
const char WiFiAPPSK[] = "";

void setup()
{
  setupWiFi();
}

void loop()
{
}

void setupWiFi()
{
  WiFi.mode(WIFI_OFF);
  WiFi.mode(WIFI_AP);

  String AP_NameString = "Futedo";

  char AP_NameChar[AP_NameString.length() + 1];
  memset(AP_NameChar, 0, AP_NameString.length() + 1);

  for (int i=0; i<AP_NameString.length(); i++)
    AP_NameChar[i] = AP_NameString.charAt(i);

  WiFi.softAP(AP_NameChar, WiFiAPPSK);
}
This is working !

I dont know when it stopped working in B4R, I have used ESP32 lately.
Arduino 1.8.12
ESP8266 2.6.3

B4R 3.30
rESP8266WiFi 1.56

Is this just me ?
 

thetahsk

Active Member
Licensed User
Longtime User
Did you update your rCore lib ?

 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Did you update your rCore lib ?

Yes I did.
This is my latest discovery:
I tried the NistTime example and there was my AP and it is not even initialized in the new project.
Then i added this to my test:
B4X:
    server.Initialize(62120,"server_NewConnection")
    server.listen
    astream.Initialize(server.Socket.Stream, "server_NewData", "server_Error")
Now the AP is showing up , sometimes.
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Did you update your rCore lib ?


I moved the Arduino code to B4r:
B4X:
public Sub StartAP
    RunNative("setupwifi", Null)
End Sub

#if C
void setupwifi(B4R::Object* o) {
    WiFi.mode(WIFI_OFF);
    WiFi.mode(WIFI_AP);
    String AP_NameString = "Futedo.com";
    char AP_NameChar[AP_NameString.length() + 1];
    memset(AP_NameChar, 0, AP_NameString.length() + 1);
    for (int i=0; i<AP_NameString.length(); i++)
    AP_NameChar[i] = AP_NameString.charAt(i);
    WiFi.softAP(AP_NameChar);
}
#End If

Compiling and uploading in Arduino works everytime.
Compiling and uploading in B4R never works.

Using the same board, NodeMCU 1.0 with the same boards settings.
Sketch and Globals are almost the same.
Output from esptool.py is the same.
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Where are the logs?

Here are
the Arduino sketch that works.
B4R project 1 and log.
B4R project 2 using arduino C and log.
Only the Arduino sketch starts the AP.
 

Attachments

  • sketchAP.zip
    385 bytes · Views: 342
  • TestAP1.zip
    808 bytes · Views: 333
  • Log1.txt
    280 KB · Views: 331
  • TestAP2.zip
    899 bytes · Views: 315
  • Log2.txt
    109.5 KB · Views: 340
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Yes, and I have also tried everything I read about like this:
B4X:
Public Sub SetPHYmode
    RunNative("setphymode", Null)
End Sub

Public Sub EraseConfig
    RunNative("eraseconfig", Null)
End Sub

#if C
#include "user_interface.h"

void setphymode(B4R::Object* o) {
    wifi_set_phy_mode(PHY_MODE_11B);
}

void eraseconfig(B4R::Object* o) {
    ESP.eraseConfig();
}
#End If

But what I am most curious about is, why the same code acts differently in Arduino and B4R
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Try the server example from that link. It enables AP mode and it should work.
Yes. Now I have tested the server example and my own even simpler project.
Both are working fine, on all my Ali boards.
The difference is that now I have my own PCB with an Esp8266.
Maybee this chip has not been prepared properly.
On this board everything is working nicely, except Access point.
If I use Arduino and upload the small sketch from post #1, the access point is working.
But using B4R the access point is not showing.

Here you can see firmware for an ESP8266
This firmware are distributed with Arduino and Arduino produces a Bin file where everything is included.
The ' esp_init_data_default.bin ' file contains the RF settings for WiFi.

Is it possible that a Bin file created with B4R is missing this file?
 
Upvote 0

BertI

Member
Licensed User
Longtime User
Just to say that a few weeks ago I experienced a similar set of symptoms. I was working with an ESP-12F on the same PCB as I had with others. The symptoms were quite strange - I would actually see the access point start up (sometimes) but the times that it remained stable for long enough it would then disappear when I tried to connect to it. I initially thought it might be a hardware tolerance related issue e.g. not decoupling the supply close enough or well enough, such that maybe when the radio was working harder (if it did during AP connect) it might cause a drop out. However having tried a few changes with components to no effect (supply was 1A capacity so wasn't on edge of ability to deliver the necessary current and decoupling capacitors soldered as direct as possible to the board pads) there was no change and as you say - the odd thing is that it worked ok with Arduino code. In the end I just replaced the device but unfortunately the new one was from a new batch so adding another variable. Makes me wonder if there are indeed some detailed underlying wifi settings which are different and the differences are affecting some edge of tolerance devices
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
This is my B4R Project:
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
End Sub

Private Sub AppStart
    RunNative("setupwifi", Null)
End Sub

#if C
#include <ESP8266WiFi.h>
void setupwifi(B4R::Object* o) {
    WiFi.mode(WIFI_OFF);
    WiFi.mode(WIFI_AP);
    String AP_NameString = "Futedo.com";
    char AP_NameChar[AP_NameString.length() + 1];
    memset(AP_NameChar, 0, AP_NameString.length() + 1);
    for (int i=0; i<AP_NameString.length(); i++)
    AP_NameChar[i] = AP_NameString.charAt(i);
    WiFi.softAP(AP_NameChar);
}
#End If

I think it is exactly the same as this Arduino sketch:

B4X:
#include <ESP8266WiFi.h>

void setup() {
  setupWiFi();
}

void loop() {
}

void setupWiFi() {
  WiFi.mode(WIFI_OFF);
  WiFi.mode(WIFI_AP);

  String AP_NameString = "Futedo.com";

  char AP_NameChar[AP_NameString.length() + 1];
  memset(AP_NameChar, 0, AP_NameString.length() + 1);

  for (int i=0; i<AP_NameString.length(); i++)
    AP_NameChar[i] = AP_NameString.charAt(i);

  WiFi.softAP(AP_NameChar);
}

Uploading from B4R, does not start access point.
Opening the B4R project created under Objects\src in Arduino and uploading from Arduino, does not start access point.
Uploading the Arduino sketch from Arduino, the access point is working !!

Attached is the created sketch from B4R.
 

Attachments

  • src.zip
    16.8 KB · Views: 342
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
I still wonder why Access point is working, when deployed using Arduino and not using B4R.
BUT here is how to get to work in B4R :)

My latest batch of PCB's was equipped with completely empty Esp8266.
I had the understanding that uploading a bin file changed all code , but apparently something are missing.
So I used this tool and uploaded these files using these settings
Tool.jpg

This will give you an AT command interface and it will open an access point.
After that you can use both Arduino and B4R and everything works.
 
Upvote 0

BertI

Member
Licensed User
Longtime User
The tool version which your above link pointed to I found to be V3.6.8. Does this mean you had an older copy of the tool or am I looking at something different? Also, where did the 4 files shown in your picture come from?

Something that I don't understand - you say the ESP8266 was 'empty' but after you download these files then both Arduino and B4R work ok, but then why did it work with Arduino and not B4R before these files were downloaded?
 
Upvote 0
Top