I’m currently working on a two-legged example application for Particle device setup that uses react native. We were looking at getting something up and running for our company, so I figured I’d open source it in case anyone else is in need of something similar. If you’re curious or want to help, the repo is here. It’s very early stage right now, so pardon any messes.
Anyway, I’m struggling to find a decent way to encrypt the passwords that people input for their Wi-Fi network. If doing a manual setup, you would use node-rsa, but that doesn’t seem to be compatible with react native.
Does anyone know of a good alternative that can properly parse and use the public key from the Particle devices?
It’s pretty easy to set up, and in fact I believe RSA to be quite necessary if you are using the built in system firmware to handle the credentials. I’ve adapted some code from a few other folks into a standalone version that would be easily adapted into a React Native app.
You can just use standalone RSA code, as I have. I just stood up a quick repo that should give you a pretty solid start if you need it:
I am going to pass your code on to our react native developer.
As I understand it, this would have the app connect to the Particle’s SoftAP, and program it to use the local wifi.
If this were to be used for a product (our earthquake alarm device), does this device setup code also log the user’s information in the app ? or do we have to record who we ship to along with their particular device ID ?
this would have the app connect to the Particle’s SoftAP
Yeah. I have this set up as a super simple static html/javascript app, so native api functionality isn't assumed. Because of this my app as is doesn't connect to the AP for you. However, you can easily set both the softAP prefix and suffix in the firmware such that you could fairly easily automate the connection to the appropriate softAP using native api stuff. If you use the built in pseudo random suffixes and set your own prefix (in my sample code I explicitly set it to "PHOTON" ) say to something like "ALARM" then you just automatically connect to (or list out for user selection) any available access point with the form "ALARM-XXXX" and then continue the configuration process once connected.
or do we have to record who we ship to along with their particular device ID ?
So there is a commented out function at the bottom of script.js in that repo that allows you to retrieve the device ID over softAP. You can call this automatically upon connection or otherwise as needed. It may need some slight adaptation, but should be straightforward.
Assuming that your app will have some user information (a login of some kind), then you should be able to upload that device ID as needed attached to that user info once the setup is complete and the user is connected to the internet again.