Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis issue, can't generate uuids #1

Open
mcinnes01 opened this issue Feb 11, 2015 · 7 comments
Open

Redis issue, can't generate uuids #1

mcinnes01 opened this issue Feb 11, 2015 · 7 comments

Comments

@mcinnes01
Copy link

Hi @brianehlert

Just being playing with meshblu trying to generate a UUID for an arduino with:

curl -X POST -d "type=firmwareController&payloadOnly=true&name=Arduino" http://UbuntuServer:3000/devices

Also tried generating a UUID with NodeBlu and adding a new MeshBlu server and using the generate option to no avail. I get the following:

image

This is the error logs on the server

image

Any ideas what I am doing wrong?

Many thanks

Andy

@brianehlert
Copy link
Owner

If I recall properly you are running Windows, right? I ask since my REST commands in are PowerShell ;-)
Did you set the UUID and token in the sketch prior to uploading the sketch to the Arduino? You need that information to be able to do anything with it. And you have to modify the object and set it as payload only.

Here is my test. It is basically a walkthrough scenario.
(NOTE: This is PowerShell folks!)

check 'status' of Meshblu
Invoke-RestMethod -URI http://<your meshblu>:3000/status -ContentType "application/json" -Method Get

Add yourself as a 'developer' to a Meshblu instance so that you can query objects (a 'device' is simply an object) - this is the minimum
$body = @{ "type" = "user" }

better way to add yourself:
$body = @{ "type" = "user"; "email" = "[email protected]"; "name" = "Brian Ehlert" }

$json_body = $body | ConvertTo-Json

$objMe = Invoke-RestMethod -URI http://<your meshblu>:3000/devices -ContentType "application/json" -Body $json_body -Method Post

"$objMe" contains the uuid and token that needs to be used in the header to 'authenticate'

$meAuthHeader = @{ meshblu_auth_uuid = $objMe.uuid; meshblu_auth_token = $objMe.token }

list 'public' devices
$allDevices = Invoke-RestMethod -URI http://<your meshblu>:3000/devices -Headers $meAuthHeader -Method Get $allDevices.devices

claim a device
Invoke-RestMethod -URI ("http://<your meshblu>/claimdevice/" + $device.Uuid ) -ContentType "application/json" -Headers $meAuthHeader -Method Put

$device.Uuid is something that you should already know. Since you own the arduino.

@brianehlert
Copy link
Owner

I see Redis connection refused.
Your Redis server should not be asking for authentication and you should not have it defined in your configuration.
I am assuming that you copied my gitAppliance.sh, Ubuntu_meshblu.conf, and meshbluConfig.js to your home directory and ran gitAppliance.sh

@mcinnes01
Copy link
Author

Hi @brianehlert

I sure did, I didn't change the config and left it as is, just renaming as you described to "meshblu.conf".

Following the powershell commands I get this, which I guess is due to the redis issue?

image

Here is the files in the home directory as you described and I ran ./gitAppliance.sh

image

Is there some config change required in relation to redis?

Many thanks

Andy

@brianehlert
Copy link
Owner

The script should have installed a local Redis server and also be connecting to it on 'localhost'
And it is possible that 'localhost' is messed up in the hosts file.

If you go to /var/www/meshblu and edit config.js nano /var/www/meshblu/config.js
You can comment out the four redis configuration lines. Redis is not important.
Then save with ctrl + x and be sure to say yes.

Then reboot sudo shutdown now -r

The REST error. Your screen shot looks like you missed a step:
$json_body = $body | ConvertTo-Json

Prior to the POST

@mcinnes01
Copy link
Author

Hi @brianehlert

This is my hosts file I did edit it following some instructions about setting up ubuntu

image

I'll try disabling it for now, but it would be cool to work out what's going wrong.

I'll try without and let you know how I get on.

Thanks again for the help!

Andy

@mcinnes01
Copy link
Author

Hi @brianehlert

I commented out the redis config, rebooted and tried the steps described above and I get the following error:

image

Interestingly if I check the status I still get "online"

image

Not sure why it doesn't want to play ball, everything is vanilla with no extras installed?

Many thanks

Andy

@brianehlert
Copy link
Owner

Hard to truly know without seeing it myself, since this is an app talking to another service.
Be sure that your $body and $json_body are populated. But then I would expect and unauthenticated error.
try formatting the $body a bit differently.
try only: $body = @{ "type" = "user" }
Then convert to json, then feed in.
I honestly have not had that problem with Windows 8.1 (PowerShell v4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants