spirilis 1,265 Posted September 30, 2014 Share Posted September 30, 2014 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. reaper7 1 Quote Link to post Share on other sites
spirilis 1,265 Posted September 30, 2014 Share Posted September 30, 2014 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 Quote Link to post Share on other sites
energia 485 Posted September 30, 2014 Share Posted September 30, 2014 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) reaper7 1 Quote Link to post Share on other sites
reaper7 67 Posted October 1, 2014 Share Posted October 1, 2014 @@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! Quote Link to post Share on other sites
MORA99 9 Posted October 1, 2014 Author Share Posted October 1, 2014 Very nice, now if only we could get smartConfig and networkBootloader Quote Link to post Share on other sites
reaper7 67 Posted October 1, 2014 Share Posted October 1, 2014 @@MORA99 - as I wrote above ... more examples we have int WiFiClass::startSmartConfig(); Quote Link to post Share on other sites
hlipka 11 Posted October 1, 2014 Share Posted October 1, 2014 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. Quote Link to post Share on other sites
spirilis 1,265 Posted October 1, 2014 Share Posted October 1, 2014 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. Quote Link to post Share on other sites
spirilis 1,265 Posted October 10, 2014 Share Posted October 10, 2014 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. Quote Link to post Share on other sites
spirilis 1,265 Posted October 16, 2014 Share Posted October 16, 2014 Redid all the deviceIp/Mac/whatever functions to use the new MACAddress class I created. Pushed to the issue_480 pull request. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.