particle-iot / spark-server

UNMAINTAINED - An API compatible open source server for interacting with devices speaking the spark-protocol
https://www.particle.io/
GNU Affero General Public License v3.0
441 stars 136 forks source link

Test more fully with the Photon! #45

Open dmiddlecamp opened 9 years ago

dmiddlecamp commented 9 years ago

Things to include:

zsup commented 9 years ago

@dmiddlecamp @emilyrose what testing have we done with the Photon on spark-server? Can we confirm what is known to work?

dmiddlecamp commented 9 years ago

I'm not aware of any specific photon testing so far on the local server, but we should expect all normal protocol bits to work. The photon more or less doesn't get any special accommodations server side except we skip requesting the describe payload before auto-update (which the local server doesn't do.)

zsup commented 9 years ago

@kennethlimcp I'm guessing you've played with this - have you tried the Photon with spark-server? Any reports?

KarbonDallas commented 9 years ago

I have not personally done any testing with spark-server yet, but am happy to when we decide to give it priority!

kennethlimcp commented 9 years ago

@zsup i haven't done anything with Photon + spark-server but i can try things out :)

zsup commented 9 years ago

@kennethlimcp would love your help if you've got a sec to play with it!

kennethlimcp commented 9 years ago

@zsup,

Just tested and the handshake failed with:

Handshake failed: plaintext was the wrong size: 214 { ip: '192.168.2.6', cache_key: '_4', coreID: null }

dmiddlecamp commented 9 years ago

Ah sure, that's a quick fix, thanks!

Sent from my iPhone

On May 30, 2015, at 9:39 AM, Kenneth Lim notifications@github.com wrote:

@zsup,

Just tested and the handshake failed with:

Handshake failed: plaintext was the wrong size: 214 { ip: '192.168.2.6', cache_key: '_4', coreID: null }

— Reply to this email directly or view it on GitHub.

kennethlimcp commented 9 years ago

I override the check here: https://github.com/spark/spark-protocol/blob/master/js/lib/Handshake.js#L343 and the photon went online.

Tested OTA which did not work. I think we need to wait for more tests to be done but for now i think the cloud functions should work (never tested)

javier-rodas commented 9 years ago

@kennethlimcp @emilyrose Hi, I was testing the Photon with the local cloud and everything but the OTA works (server interruptions correctly managed, events, calls, keys, etc.).

How to reproduce the issue:

$ particle list
XXXXXXX [3a00300003XXXXXXXXXXXXXX] is online
  Functions:
    int function1(String args) 
    int function2(String args) 

$ particle flash 3a00300003XXXXXXXXXXXXXX tinker.bin
Including:
    tinker.bin
attempting to flash firmware to your device 3a00300003XXXXXXXXXXXXXX
flash device said  {"id":"3a00300003XXXXXXXXXXXXXX","status":"Update started"}

$ particle list
XXXXXXX [3a00300003XXXXXXXXXXXXXX] is online
  Functions:
    int function1(String args) 
    int function2(String args) 

After this call the LED changed to a fixed magenta color during aprox. 1s and then the photon was restarted (LED in white, then green, cyan, etc.). So it didn't start blinking in magenta as when the firmware is really being flashed.

Do you have any timelines for a new spark-server release that support the OTA updates with the Photon?, or is there any workaround that could be applied to the spark-firmware (develop 0.4.3) or to the spark-server code to support OTA upgrades in the local cloud?

Thanks!.

javier-rodas commented 8 years ago

Hi again.

I have discovered that the fixed magenta color during aprox. 1s observed during the failing OTA update is similar to when the module manually enters in Ymodem mode by changing the USB device baudrate to 28800.

I don't know if this comment helps or not... I'm just trying to understand why is the OTA update not currently working with the Photon in the local :cloud: :disappointed:

N6UDP commented 8 years ago

I can't get the photon to work at all locally.. after commenting out the handshake check and then running key doctor (and placing the pub file in the right place):

After loading a key unto my photon:

CryptoStream transform error TypeError: Cannot read property 'length' of null
CryptoStream transform error TypeError: Cannot read property 'length' of null
on ready { coreID: '370029000747343232363230',
  ip: '::ffff:44.44.92.215',
  product_id: 6,
  firmware_version: 65535,
  cache_key: '_0' }
Core online!
CryptoStream transform error TypeError: Cannot read property 'length' of null
CryptoStream transform error TypeError: Cannot read property 'length' of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 2
routeMessage got a NULL coap message  { coreID: '370029000747343232363230' }
CryptoStream transform error TypeError: Cannot read property 'length' of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 3
routeMessage got a NULL coap message  { coreID: '370029000747343232363230' }
CryptoStream transform error Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
Coap Error: Error: Unknown message code: 254
routeMessage got a NULL coap message  { coreID: '370029000747343232363230' }

It sorta looks like it saved? There is an error at the bottom but dfu did write /something/:

dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 2b04:d006
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "DCT Flash   "
Downloading to address = 0x00000022, size = 608
Download        [=========================] 100%          608 bytes
Download done.
File downloaded successfully
Error during download get_status
Error saving key to device...
javier-rodas commented 8 years ago

Hey @lrburton try this starting from the latest 0.4.3 develop firmware source code.

N6UDP commented 8 years ago

@javier-rodas unless I'm missing something that's for local flashing -- I'm having issues connecting the photon to the local spark-server instance. The photon is running 0.4.3 fwiw.

javier-rodas commented 8 years ago

@lrburton just make sure to update both the modules and the main firmware before trying to connect to your local :cloud: as explained in the link I gave you.

I would start trying only with the first step (with modules -> program-dfu, which rewrites 2 module firmware parts plus the default tinker app), and then I would try connecting to the global Particle :cloud:

Then I would just update the public key and static IP of the local :cloud: in the Photon using:

$ particle keys server default_key.pub.pem 192.168.0.X

where default_key.pub.pem is your local :cloud: public key. You can find it in your spark-server directory.

If you want to reverse the public key and use again the global Particle :cloud: you should use the der file that can be downloaded from here and update it without giving any IP address to this command:

$ particle keys server cloud_public.der

Finally I would try with the second step (compiling from the main directory -> program-dfu), to write my own custom app in the Photon.

N6UDP commented 8 years ago

I've got part1/part2/tinkervlatest of the 0.4.3 update on my 2 photons and they work fine with the public cloud. I reverted the one I had pointed at my local cloud with:

particle keys server cloud_public.der
particle config spark
particle cloud login
particle keys send 370029000747343232363230 370029000747343232363230_new.pub.pem

And it seems to work just fine on the public cloud -- the local server was throwing errors but the photon did breath cyan some of the time when connected to the local server.

Attempting to move it back to my private cloud:

particle keys server spark-server\default_key.pub.pem 44.44.92.3
particle config local apiUrl http://44.44.92.3:8080
particle keys send 370029000747343232363230 370029000747343232363230_new.pub.pem

results in the errors I saw above (but with the photon breathing cyan except ever few seconds when it reconnects) after commenting out the check @ https://github.com/spark/spark-protocol/blob/827ded3f20d43fa0ffe2e092a2316998c8b4812d/js/lib/Handshake.js#L343

Unlike particle keys doctor (in my first post) all of the commands above completed entirely successfully according to their output.

Are you using a different version of spark-server / spark-protocol? Or do you see something wrong with the above?

Thanks, Lee

javier-rodas commented 8 years ago

@lrburton In which operating system are you testing this? And, have you correctly installed all the dependences as commented in the README files of the spark-server, particle-cli and spark-firmware?

Please review that, because in your log I see some problems related to the CoAP version:

CryptoStream transform error TypeError: Cannot read property 'length' of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 2
dmiddlecamp commented 8 years ago

Hi All,

The photon firmware behaves slightly differently during the handshake, I'll be submitting a pull-request to the spark-protocol project hopefully today that should resolve the handshake errors you're seeing.

Thanks! David

N6UDP commented 8 years ago

@javier-rodas Windows... I ran npm install as per the instructions in spark-server readme .. I don't have repo locally for spark-firmware but also ran npm to install particle-cli. Are the other dependencies I'm missing? Readme/Install don't say to have anything additionally..

dmiddlecamp commented 7 years ago

I'd like to close out the photon / local cloud issues if possible. I've tested this recently and the photon seems to be working as expected. Can someone who was having this issue confirm it's fixed or still a problem?

Thanks! David