Jump to content
MORA99

CC3200 Wifi delay issue

Recommended Posts

I'll add something like that... was having trouble coming up with function names for how to name it :)

edit: eh, another goofy detail is there's no MACAddress class for storing & dumping MACs.  might have to make one...

Ok, here we go...

Client connected!  All clients:
Client 0 at IP=192.168.1.2, MAC=88:32:9b:47:74:7d
Client disconnected.

code:

  static int peerdevs = 0;
  int nowdevs = 0;

  nowdevs = WiFi.getTotalDevices();
  if (nowdevs > peerdevs) {
    Serial.println("Client connected!  All clients:");
    for (i=0; i < nowdevs; i++) {
      Serial.print("Client "); Serial.print(i); Serial.print(" at IP=");
      Serial.print(WiFi.deviceIpAddress(i));
      Serial.print(", MAC=");
      Serial.println(WiFi.deviceMacAddress(i));
    }
  }
  if (nowdevs < peerdevs) {
    Serial.println("Client disconnected.");
  }
  peerdevs = nowdevs;

The .macAddress() function was already taken so prepending device to those names makes more sense to me.  deviceMacAddress() writes a string to a privately-kept buffer that gets overwritten each subsequent execution of the command, that buffer is then returned as a const char * string for printing.  If we decide to make a MACAddress class to go alongside IPAddress, that will be improved.

 

Change committed to git (branch issue_480) for CC3200 & msp430/lm4f CC3100.

Share this post


Link to post
Share on other sites

Probably also want a .deviceIpFromMac and .deviceMacFromIp because the indexes can renumerate if one below its index in number disconnects. Robots could autonomously attach and communicate with a central WiFi AP broker MCU with this.

 

Sent from my Galaxy Note II with Tapatalk 4

Share this post


Link to post
Share on other sites

Awesome! These functions can be used to filter, identify, etc connected clients..

 

The private buffer could potentially be dangerous if users make the assumption that the pointer returned is unique and pointing to which ever device I asked it for.

Would a similar implementation as the .macAddress() work better?

uint8_t* WiFiClass::deviceMacAddress(uint8_t* mac)

Share this post


Link to post
Share on other sites

@@energia @@spirilis - maybe some example for AP mode, which uses this new stuff?

 

Probably not everyone (with me on top) knows how to completely run the AP mode

with WiFi.beginNetwork(ssid), WiFi.status = WL_AP_MODE instead WL_CONNECTED (in STA mode)

 

tnx!

Share this post


Link to post
Share on other sites

One big caveat is the TCP connection needs to be SSL from the get-go; I don't see any way the CC3100 stack will let you open an unencrypted connection and then convert it into an SSL link (STARTTLS style).

The SSL demo project for the CC3200 explitely says that a connection cannot be up-graded to use SSL (nor can it be down-graded). It also mentions this as a limitation of the CC3200.

Share this post


Link to post
Share on other sites

 

Awesome! These functions can be used to filter, identify, etc connected clients..

 

The private buffer could potentially be dangerous if users make the assumption that the pointer returned is unique and pointing to which ever device I asked it for.

Would a similar implementation as the .macAddress() work better?

uint8_t* WiFiClass::deviceMacAddress(uint8_t* mac)

Could do it that way, where the buffer is provided by the user.  I'll make that change now and push to the branch.

Share this post


Link to post
Share on other sites

Came up with a .deviceIpByMacAddress(const uint8_t *mac) and .deviceMacByIpAddress(IPAddress ip, char *sbuf) for obtaining an IPAddress object by 6-byte binary MAC, and user-readable MAC address from an IPAddress object.  Note those 2 are not reciprocals; the .deviceIpByMacAddress() expects the MAC in a 6-byte binary format, unlike the string returned by .deviceMacByIpAddress().

Attempting to connect to Network named: Test

You're connected to the network
Waiting for an ip address

IP Address obtained
SSID: Test
IP Address: 192.168.1.1
signal strength (RSSI):0 dBm
To see this page in action, open a browser to http://192.168.1.1
Starting webserver on port 80
Webserver started!
Client connected!  All clients:
Client 0 at IP=192.168.1.2, MAC=88:32:9b:47:74:7d
IP from phone: 192.168.1.2
MAC by phone IP: 88:32:9b:47:74:7d
Client disconnected.

Gotta copy my code over to msp430 and cc3200 (working with Tiva + CC3100 right now) and push to the branch.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×