Alternate Portal

Related to the Portal
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Alternate Portal

Post by chachew »

binder wrote:yes we can get json data, check ra_wifi.cpp file and it will show you the data.


Sent from my iPad mini
How am i getting this via locally hosted site?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

i dont follow. if you look in your libraries folder for the ra_wifi.cpp file, that will tell you the command you can issue to your controller to retrieve the json data for usage.


Sent from my iPad mini
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Alternate Portal

Post by chachew »

binder wrote:i dont follow. if you look in your libraries folder for the ra_wifi.cpp file, that will tell you the command you can issue to your controller to retrieve the json data for usage.


Sent from my iPad mini
I see it now, i had to update my libraries first ;)

Thanks
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Alternate Portal

Post by chachew »

So i have a question. Is the goal of the local www app to get controller data from the 'users' internal network or from the reef angel db? I havent downloaded the android app yet but was just wondering what the ultimate goal was for the www app.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Alternate Portal

Post by lnevo »

either, the controller is live, the db has things like labels and port names but is 5 minute data.
User avatar
chachew
Posts: 84
Joined: Sat Aug 04, 2012 11:52 pm
Location: Pearland, TX

Re: Alternate Portal

Post by chachew »

lnevo wrote:either, the controller is live, the db has things like labels and port names but is 5 minute data.
It just brings me back to the problem i stated above. There is NO WAY you can make a website perform XML cross-domain calls. JSON, yes. XML, nope

--EDIT--
OK after some code changes i DO have the 'Download Labels from Portal' function working. Now keep in mind this is using a YQL query that acts as a proxy. This is to get past the cross-domain issues that i have stated before. This will work for any scenario where the local app needs to talk to reefangel.com for downloading any type of XML data. As i have stated before the YQL calls have hourly/daily limits and COULD cause a problem if a user is over using the query via webpage updates.

If a anyone is interested to see just that part working let me know and i can upload a .zip with the few changes in it that i have made. :D
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Alternate Portal

Post by lnevo »

I'm sure roberto can dump json for the labels
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

i've been working on this portal today and now I'm running into some issues trying to send data from my controller. I've changed the libraries to reference my submit script (/ra/submitp.php?....). I've added in the ReefAngel.Portal() command to send the data. If I connect to the serial monitor, I see the data get sent.
My problem is I don't think my wifi module is configured correctly. I've talked with Roberto and he told me what he has set to work with the standard portal. I had to set the Host and Port to be the IP address of the server in use. I tried my internal network address and also my external network address but nothing.
I used the

Code: Select all

set ip host XXX.XXX.XXX.XXX
set ip remote 80
Do I need to change anything else from the wifi module?
Here's some output of the settings:

Code: Select all

<4.00> 
get w

SSID=BinderWifi
Chan=0
ExtAnt=0
Join=1
Auth=MIXED
Mask=0x1fff
Rate=12, 24 Mb
Linkmon-Infra=30
Linkmon-AP=3600
Passphrase=
EAP_Id=userid
EAP_User=peap-user

<4.00> 
get i

IF=UP
DHCP=CACHE
IP=10.0.42.41:2000
NM=255.255.255.0
GW=10.0.42.1
HOST=98.253.61.42:80
PROTO=TCP,
MTU=1524
FLAGS=0x7
TCPMODE=0x0
BACKUP=0.0.0.0
I was thinking that I may have to change some other settings, but I am not 100% positive. Anybody have some ideas? Or do I need to share more output from my wifi module?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Alternate Portal

Post by rimai »

send the get a dump
I think something got messed up when you did the reset.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

rimai wrote:send the get a dump
I think something got messed up when you did the reset.
I think you are right. Here's the output:

Code: Select all

<4.00> 
get a

Beacon=102
Reboot=0
<4.00> 
get e

wifly-GSX Ver 4.00.1, Apr 19 2013 11:48:31 on 131C94
Beacon=102
Reboot=0
IF=UP
DHCP=CACHE
IP=10.0.42.41:2000
NM=255.255.255.0
GW=10.0.42.1
HOST=98.253.61.42:80
PROTO=TCP,
MTU=1524
FLAGS=0x7
TCPMODE=0x0
BACKUP=0.0.0.0
OPEN=
CLOSE=
REMOTE=
FlushSize=1024
MatchChar=0
FlushTimer=5
IdleTimer=3
CmdChar=$
DNS=10.0.42.1
Name=dns1
Backup=rn.microchip.com
Lease=86400
FTP=0.0.0.0:21
File=wifly-GSX.img
User=roving
Pass=Pass123
Dir=public
Timeout=200
FTP_mode=0x0
SSID=BinderWifi
Chan=0
ExtAnt=0
Join=1
Auth=MIXED
Mask=0x1fff
Rate=12, 24 Mb
Linkmon-Infra=30
Linkmon-AP=3600
Passphrase=
EAP_Id=userid
EAP_User=peap-user
SleepTmr=0
WakeTmr=0
Trigger=0x1
Autoconn=0
IoFunc=0x0
IoMask=0x20f0
IoValu=0x0
DebugReg=0x0
PrintLvl=0x0
LaunchStr=web_app
TimeEna=0
TIMEADR=64.90.182.55:123
Zone=7
Baudrate=57600
Flow=0x0
Mode=0x0
Cmd_GPIO=0
JoinTmr=1000
Replace=0x24
DeviceId=WiFly-GSX
Password=
Format=0x0
Signal=0
Average=5
BCAST=255.255.255.255:55555
Interval=0x7
Backup=0.0.0.0:0
Sensor=0x0
SensePwr=0x0
<4.00> 
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Alternate Portal

Post by rimai »

And you said that it does the same thing when using an internal ip as well?
I just want to eliminate the loopback issue.
Did you try sniffing the network traffic to see if the server is getting any connection at all, even if it is broken?
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

rimai wrote:And you said that it does the same thing when using an internal ip as well?
I just want to eliminate the loopback issue.
Did you try sniffing the network traffic to see if the server is getting any connection at all, even if it is broken?
Correct. internal and external ip yields same result. not a loopback issue. my router handles the loopback appropriately.

no, i have not sniffed any network traffic yet. that will be the next step. i was also going to try to use the wifi utility to reprogram my wifi module thinking that may help. i will see what i come up with today.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

I figured out my problem and got things working. I used the wifi utility to program my module so I could see how the defaults were set. Turns out, I was only doing half of what I needed to do in regards to getting it to update. Now I haven't tested this more because it is working, but this is what I needed to do. I needed to change the host ip to my public ip and my host dns name to my public domain name.

Code: Select all

set ip host XXX.XXX.XXX.XXX
set dns name my.domain.name
I'm sure I could have set things to be based solely on my internal network but I opted to go this route. I will have to test more in the future. As soon as I plugged the module back into my controller and started viewing my webserver logs, I could see the requests and commands coming through just fine. So I know that works now and that I can receive the data from the controller. On to pulling the data from my database..... :ugeek:
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

success!!!

i now have my own portal logging my data for me. i can receive the data from my controller and i can pull the data from it using my android app (i have it tweaked to work with my portal specifically though for testing).

i don't have anything being displayed on the webserver for my portal other than listing what devices are connected and giving a form to add a new device. this can be fixed in the future though.

the good news is everything works and can be deployed easily for people. so you could run your own custom portal/data logger on something like a raspberry pi (hence my internal name raPiPortal). i have to continue to tweak the main page and the settings and everything but it's looking pretty good and working fairly well for me so far. this could be great for those with multiple devices (like a fish shop or dealer or something) or someone who wants to keep all their data "in-house" and do other things with the data.

anyways, just thought i'd share my progress. :geek:
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Alternate Portal

Post by rimai »

Awesome!!!
Roberto.
User avatar
joshlawless
Posts: 138
Joined: Thu May 23, 2013 2:52 pm

Re: Alternate Portal

Post by joshlawless »

Just wanted to stick my head in this and announce I'd be very interested in this feature, even if it required some legwork.

I'd be much more comfortable in the security of my tank if I could have the WiFi module communicating with a webserver on my LAN, behind my firewall, to avoid the port-forwarding and the reliance on basic HTTP auth to protect my tank from unauthorized tinkering.

If you were willing to share the changes you made to the libraries, the configuration you passed with the WiFi utility, and the code running on your webserver, I'd be very grateful.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

joshlawless wrote:Just wanted to stick my head in this and announce I'd be very interested in this feature, even if it required some legwork.

I'd be much more comfortable in the security of my tank if I could have the WiFi module communicating with a webserver on my LAN, behind my firewall, to avoid the port-forwarding and the reliance on basic HTTP auth to protect my tank from unauthorized tinkering.

If you were willing to share the changes you made to the libraries, the configuration you passed with the WiFi utility, and the code running on your webserver, I'd be very grateful.
sure thing.

i just pushed the webserver code to my github account:
https://github.com/curtbinder/rapiportal

i added comments to the README file on how to set it up. hopefully i got all the steps in there. i haven't really messed with this since last year. i was going on my comments and code.

this is just a bare basics start. my php skills are very limited. i also have not updated the database code to reflect the newer fields in the database.

also, i believe you need to create the "device" in the database first. the "device" is the name you use inside the Portal("username"); command. Typically that is your portal username but this custom portal will allow you to have multiple devices all sending data to it. so you can create your own names and such.

feel free to look around the code and test it out and all. i may add in more comments about setting it up and possibly fill in the missing database fields for it to handle....just depends on what all i have going on this weekend. if i get the backend working good, then the main thing would be to get a simple frontend created for displaying the data. i know it sends the data out just fine when queried because i had it working with my android app.

anyways, let me know if you have questions.
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Alternate Portal

Post by Smotz »

following..
dlplunkett44
Posts: 74
Joined: Mon Aug 05, 2013 3:16 am

Re: Alternate Portal

Post by dlplunkett44 »

Is this ready to be used? I am getting a raspberry pi and would love to be able to log all of the data and make graphs over time.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

dlplunkett44 wrote:Is this ready to be used? I am getting a raspberry pi and would love to be able to log all of the data and make graphs over time.
I haven't worked on it in a while. it needs to be updated to handle the newer commands. It also does not have any specific interface for it. I didn't have a lot of time for it and there didn't seem to be a lot of interest in it either.
Do you have any coding experience? would you be able to help?

Sent from my XT1585 using Tapatalk
dlplunkett44
Posts: 74
Joined: Mon Aug 05, 2013 3:16 am

Re: Alternate Portal

Post by dlplunkett44 »

I do not have much coding experience but I am willing to learn what is necessary. What is the current state of this? What newer commands is it not able to do? As far as an interface, do you mean a web page to display the data? Is it capable of storing the data into a database?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

dlplunkett44 wrote:I do not have much coding experience but I am willing to learn what is necessary. What is the current state of this? What newer commands is it not able to do? As far as an interface, do you mean a web page to display the data? Is it capable of storing the data into a database?
In it's current state, it should be able to store the data in a database (i believe it's set for SQLite database). I don't recall how / if it displays the data on a web page. It is designed to be used for internal usages because of no authentication and such.
It only receives data and can serve data in terms of sending out the status requests. It does not issue any commands to the controller, nor does it accept commands to be relayed.
I would have to test it and see what it does since I do not recall off hand.
It is written in PHP and an authentication, display, and management interface is needed.
dlplunkett44
Posts: 74
Joined: Mon Aug 05, 2013 3:16 am

Re: Alternate Portal

Post by dlplunkett44 »

Thanks for the info. I'm going to load it into my pi in the next few days and see where I can get with it. How often does the controller send data?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Alternate Portal

Post by binder »

dlplunkett44 wrote:Thanks for the info. I'm going to load it into my pi in the next few days and see where I can get with it. How often does the controller send data?
every 15 minutes by default but i believe that can be changed in the libraries (not user configurable, but hard coded)


Sent from my iPad using Tapatalk
Post Reply