├── .gitignore ├── LICENSE ├── README.md ├── asset-tracker-troubleshooting ├── README.md ├── assettrackerv2-labeled.png ├── gpsdump.bin └── gpsdump_ext.bin ├── authenticating-product-apis ├── README.md └── images │ ├── auth_list.png │ ├── create_client.png │ ├── product_id_or_slug.png │ └── user_token.png ├── blinking-green └── README.md ├── breathing-green └── README.md ├── classroom-tips └── README.md ├── code-size-tips └── README.md ├── create-product-webhook ├── README.md ├── console.png └── prodhook.js ├── debugging-windows-7-drivers ├── 1-device-serial.png ├── 10-electron-serial.png ├── 2-serial-driver.png ├── 3-devmgmt.png ├── 4-show-hidden.png ├── 5-photon-hidden.png ├── 6-extract.png ├── 7-browse-for-driver.png ├── 8-select-driver.png ├── 9-installer.png └── README.md ├── disabling-dfu-mode └── README.md ├── electron-3rdparty-sims ├── 01electronwithsim.png ├── 02setup3rdparty.png ├── 03devices.png └── README.md ├── electron-low-level-networking.md ├── electron-shadow-customers ├── README.md └── images │ ├── auth_list.png │ ├── create_client.png │ └── product_id_or_slug.png ├── erasing-configuration ├── README.md └── empty.bin ├── finding-device-id ├── README.md ├── android_serial1.png ├── android_serial2.png ├── devicemanager.png ├── particledev.png ├── putty.png ├── stlink.png ├── usbserialnum-linux.png ├── usbserialnum-mac.png └── usbserialnum-win.png ├── fixing-p1-keys-using-jtag ├── README.md ├── blank.png ├── notblank.png ├── privatekey.png └── stlink.jpg ├── fixing-windows-10-serial-drivers ├── README.md └── images │ ├── admin-command-prompt.png │ ├── boron-delete.png │ ├── device-manager.png │ ├── device-properties.png │ ├── driver-details.png │ ├── hidden-devices.png │ ├── libusb.png │ ├── libusbk.png │ ├── old-driver-list.png │ ├── old-driver-properties.png │ ├── old-hidden.png │ ├── old-libwdi.png │ ├── show-hidden-devices.png │ ├── show-nonpresent.png │ └── zadig.png ├── forcing-electron-ota-system-firmware-update ├── README.md └── see_in_terminal.png ├── installing-curl ├── README.md └── images │ ├── 01download.png │ ├── 02savetarget.png │ ├── 03curldir.png │ ├── 04copy.png │ ├── 05controlpanel.png │ ├── 05copy.png │ ├── 06rename.png │ ├── 06systemandsecurity.png │ ├── 07noextension.png │ ├── 08advanced.png │ ├── 08appearance.png │ ├── 09environment.png │ ├── 09folderoptions.png │ ├── 10hideext.png │ ├── 10programfiles.png │ ├── 11newfolder.png │ ├── 12rename.png │ ├── 13startsettings.png │ ├── 14settings.png │ ├── 15environmentvariables.png │ ├── 16edit.png │ ├── 17editnew.png │ ├── 18system.png │ ├── 19editvar.png │ └── 20accesstoken.png ├── installing-dfu-util ├── README.md ├── files │ └── 50-particle.rules └── images │ ├── 01zadig.png │ ├── 02download32.png │ ├── 03programfiles.png │ ├── 04dfufiles.png │ ├── 05controlpanel.png │ ├── 06systemandsecurity.png │ ├── 08advanced.png │ ├── 09environment.png │ ├── 10programfiles.png │ ├── 11newfolder.png │ ├── 12copyfiles.png │ ├── 13startsettings.png │ ├── 14settings.png │ ├── 15environmentvariables.png │ ├── 16edit.png │ ├── 17editnew.png │ ├── 18system.png │ ├── 19editvar.png │ ├── 20command.png │ ├── 21command.png │ ├── 22dfu.png │ ├── 23com.png │ └── 24zadig.png ├── installing-openssl └── README.md ├── mac-serial-tips └── README.md ├── manual-photon-claiming ├── README.md ├── images │ ├── auth_list.png │ ├── create_client.png │ ├── product_id_or_slug.png │ └── user_token.png ├── tcp-setup │ ├── app.js │ ├── package-lock.json │ └── package.json └── wifipass │ ├── package-lock.json │ ├── package.json │ └── wifipass.js ├── measuring-electron-power ├── README.md ├── battery.jpg ├── circuit.png └── meter.jpg ├── mesh-io-notes ├── README.md └── xenon.png ├── modifying-path ├── README.md └── images │ ├── 05controlpanel.png │ ├── 06systemandsecurity.png │ ├── 08advanced.png │ ├── 09environment.png │ ├── 10editvar.png │ ├── 13startsettings.png │ ├── 14settings.png │ ├── 15environmentvariables.png │ ├── 16edit.png │ └── 17editnew.png ├── particle-bootloaders └── README.md ├── particle-cli-apple-silicon └── README.md ├── particle-cli-repair └── README.md ├── particle-dev-tips ├── README.md ├── inocpp.png ├── missingfunction.png ├── multifile.png ├── nodevice.png ├── perfolder.png ├── saveindicator.png ├── subdirs.png ├── timer.png └── verifyfirst.png ├── photon-without-wifi └── README.md ├── public-private-event-tips ├── README.md └── images │ └── 01eventlog.png ├── resetkeys_photon.md ├── restoring-tinker ├── 1ios.png ├── 2android.png └── README.md ├── retained-memory-tips └── README.md ├── safemode.md ├── setting-up-asset-tracker-in-build ├── 1-select-library.png ├── 2-select-example.png ├── 3-use-example.png ├── 4-device.png ├── 5-verify.png └── README.md ├── setting-up-out-of-area-electron └── README.md ├── system-source-and-headers └── README.md ├── tinker-apn-tips ├── README.md ├── images │ ├── cloud-icon.png │ └── setup3rdparty.png └── tinker-apn.cpp ├── tplink-router ├── README.md └── images │ ├── 1-tplink.png │ ├── 2-tplink.png │ └── 3-tplink.png ├── upgrading-system-firmware ├── README.md └── images │ ├── build.png │ └── dev.png ├── usbvsserialflash.md ├── using-travis-ci-with-particle ├── README.md └── images │ ├── environment.png │ └── user_token.png └── wpa2-enterprise ├── README.md ├── TinkerDebug.cpp └── TinkerDebug070.bin /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 rickkas7 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # particle_notes 2 | Misc. mostly technical notes for Particle Photon and Electron devices 3 | -------------------------------------------------------------------------------- /asset-tracker-troubleshooting/README.md: -------------------------------------------------------------------------------- 1 | # AssetTracker Troubleshooting 2 | 3 | If you are having trouble getting a fix from your Particle AssetTracker board, this troubleshooting tool may help. It's uses a pre-built version of the 7_DataDump example from the [AssetTrackerRK](https://github.com/rickkas7/AssetTrackerRK) library. 4 | 5 | ![AssetTracker v2](assettrackerv2-labeled.png) 6 | 7 | ## Install the Particle CLI 8 | 9 | If you have not already done so, install the [Particle CLI](https://www.particle.io/products/development-tools/particle-command-line-interface). It includes the command line utility needed to install this firmware. 10 | 11 | ## Download the binary 12 | 13 | Download the [gpsdump.bin](https://github.com/rickkas7/particle_notes/raw/master/asset-tracker-troubleshooting/gpsdump.bin) file in most cases. This uses the internal antenna on the AssetTracker v2 board. 14 | 15 | If you are using an external antenna, use [gpsdump_ext.bin](https://github.com/rickkas7/particle_notes/raw/master/asset-tracker-troubleshooting/gpsdump_ext.bin), which is configured to use an external active GPS antenna connected to the AssetTracker u.FL GPS antenna connector. 16 | 17 | ## Flash the binary 18 | 19 | - Connect the Electron by USB to your computer. 20 | 21 | - Put the Electron in [DFU mode](https://docs.particle.io/guide/getting-started/modes/electron/#dfu-mode-device-firmware-upgrade-) (blinking yellow) by holding down RESET and MODE, releasing RESET and continuing to hold down MODE while the main LED blinks magenta until it blinks yellow, then release. 22 | 23 | - Open a Command Prompt or Terminal window. 24 | 25 | - Run the commands, typically: 26 | 27 | ``` 28 | cd Downloads 29 | particle flash --usb gpsdump.bin 30 | ``` 31 | 32 | If you've downloaded the binary to a different location, substitute that directory in the cd Downloads command, of course. 33 | 34 | And if you're using an external antenna: 35 | 36 | ``` 37 | particle flash --usb gpsdump_ext.bin 38 | ``` 39 | 40 | The Electron should breathe white after installation. 41 | 42 | 43 | ## Monitor the USB serial port 44 | 45 | Then monitor the USB serial port. The easiest way is usually: 46 | 47 | ``` 48 | particle serial monitor 49 | ``` 50 | 51 | ## Electron doesn't breathe white 52 | 53 | If Electron blinks green, cyan, then breathes magenta, or gets stuck at blinking green, your Electron needs to be updated to system firmware 0.5.3 or later. 54 | 55 | 56 | - Put the Electron in [DFU mode](https://docs.particle.io/guide/getting-started/modes/electron/#dfu-mode-device-firmware-upgrade-) (blinking yellow) by holding down RESET and MODE, releasing RESET and continuing to hold down MODE while the main LED blinks magenta until it blinks yellow, then release. 57 | 58 | - Run the command: 59 | 60 | ``` 61 | particle update 62 | ``` 63 | 64 | 65 | -------------------------------------------------------------------------------- /asset-tracker-troubleshooting/assettrackerv2-labeled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/asset-tracker-troubleshooting/assettrackerv2-labeled.png -------------------------------------------------------------------------------- /asset-tracker-troubleshooting/gpsdump.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/asset-tracker-troubleshooting/gpsdump.bin -------------------------------------------------------------------------------- /asset-tracker-troubleshooting/gpsdump_ext.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/asset-tracker-troubleshooting/gpsdump_ext.bin -------------------------------------------------------------------------------- /authenticating-product-apis/README.md: -------------------------------------------------------------------------------- 1 | # Authenticating Particle product APIs 2 | 3 | *Quick introduction to authenticating Particle product APIs* 4 | 5 | ## User token 6 | 7 | When you use normal, non-product APIs, you use a user token. One way to get your user token is to use the [Particle CLI](https://docs.particle.io/reference/developer-tools/cli/#particle-token-create) command `particle token create`. 8 | 9 | Remember to keep your access token secret; they allow access to your account to anyone who has the token! 10 | 11 | (All of the tokens in this document are fake, by the way.) 12 | 13 | You would use this for a command like this, to [list your devices](https://docs.particle.io/reference/api/#list-devices): 14 | 15 | ``` 16 | curl https://api.particle.io/v1/devices?access_token=ab142050967cff79dc6586c82193978b3a62cab9 17 | ``` 18 | 19 | One thing that can be confusing is that this token is only good for your user account, not your product, so this won't work for any of the product APIs. 20 | 21 | ## Creating an OAuth client 22 | 23 | In order to use the product APIs, you need a product access token. Creating one is a two-step process. The first part is to create an OAuth client. 24 | 25 | - Open your product in the [console](https://console.particle.io) 26 | - Open the **Authentication** tab. 27 | - Click **New Client**. 28 | 29 | ![Create Client](images/create_client.png) 30 | 31 | You will want to create **Two-legged Auth (Server)** client. In the next screen, you will get a token. Copy and paste this as you can't get it back again. It's also important to keep this a secret. And, it's not your product access token. 32 | 33 | ![Authentication List](images/auth_list.png) 34 | 35 | In the next steps you'll need a few things: 36 | 37 | - The **Name** field matches the name we just created above (tempmon06) 38 | - The **Client ID** field will be needed to make API calls (tempmon06-3459) 39 | - The secret client token we got when creating a new client. In the examples below, `460edfd8d70742dd1f1e75c3d5cac5973351465d` is the token we got. 40 | 41 | ## Create a product bearer token 42 | 43 | In order to use the APIs you need a product bearer token. Here's a command in curl to create one: 44 | 45 | ``` 46 | curl https://api.particle.io/oauth/token -u "tempmon06-3459:460edfd8d70742dd1f1e75c3d5cac5973351465d" -d grant_type=client_credentials 47 | ``` 48 | 49 | Note that the username and password passed in the -u option are the client ID created above and the access token for that client. 50 | 51 | That call will return something like this: 52 | 53 | ``` 54 | { 55 | "token_type": "bearer", 56 | "access_token": "5724113917ac1e1cbf80cae2e24dd27c56245bdb", 57 | "expires_in": 7776000, 58 | "refresh_token": "7ff08565378780581aa27eeb4eb92a4e4dbcc3a5" 59 | } 60 | ``` 61 | 62 | That access_token is the one you need! 63 | 64 | The reason for all of this is that the client token needs to be kept safe because it has the ability to create new tokens. The bearer token you use to authenticate individual requests has a shorter life and is more "disposable" in case it gets into the wrong hands. 65 | 66 | ## Product ID or Slug 67 | 68 | All of the product APIs include `:productIdOrSlug` in the URL. 69 | 70 | Your product ID is a number, located next to the key on the top of your product window. It's 1319 in the screenshot below. 71 | 72 | You can also use the string in the URL. In this example, its **tempmon-v100**. 73 | 74 | ![Product ID or Slug](images/product_id_or_slug.png) 75 | 76 | Armed with these two things, you can now make product API calls! 77 | 78 | Get information about your product: 79 | 80 | ``` 81 | curl https://api.particle.io/v1/products/1319?access_token=5724113917ac1e1cbf80cae2e24dd27c56245bdb 82 | ``` 83 | 84 | Or using the slug: 85 | 86 | ``` 87 | curl https://api.particle.io/v1/products/tempmon-v100?access_token=5724113917ac1e1cbf80cae2e24dd27c56245bdb 88 | ``` 89 | 90 | Get a [list of product devices](https://docs.particle.io/reference/api/#list-devices-in-a-product): 91 | 92 | ``` 93 | curl https://api.particle.io/v1/products/1319/devices?access_token=5724113917ac1e1cbf80cae2e24dd27c56245bdb 94 | ``` 95 | 96 | And so on, for all of the product APIs. 97 | 98 | 99 | -------------------------------------------------------------------------------- /authenticating-product-apis/images/auth_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/authenticating-product-apis/images/auth_list.png -------------------------------------------------------------------------------- /authenticating-product-apis/images/create_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/authenticating-product-apis/images/create_client.png -------------------------------------------------------------------------------- /authenticating-product-apis/images/product_id_or_slug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/authenticating-product-apis/images/product_id_or_slug.png -------------------------------------------------------------------------------- /authenticating-product-apis/images/user_token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/authenticating-product-apis/images/user_token.png -------------------------------------------------------------------------------- /blinking-green/README.md: -------------------------------------------------------------------------------- 1 | # Blinking Green (Wi-Fi Connection) Issues 2 | 3 | If you configure your Photon (or P1) and only get to blinking green, here are some tips that may help: 4 | 5 | First, a few known working situations that the Photon is not compatible with: 6 | 7 | - If you are using a corporate or school network that uses WPA2 Enterprise, the Photon cannot be used at this time. If you require both a username and a password, or see a mention of 802.1(x), or RADIUS you're using WPA2 Enterprise. 8 | 9 | - If you are using a network that takes you to a web page where you need to either sign in or agree to terms and service when you first connect, using the Photon directly will be difficult or impossible. This is the case in some hotels and public Wi-Fi networks and is often referred to as Captive Portal. 10 | 11 | - If your Wi-Fi network uses 5 GHz only, instead of the more common 2.4 GHz, the Photon cannot be used. The Wi-Fi radio is only compatible with 2.4 GHz networks. 12 | 13 | For home users: 14 | 15 | - If your router uses WEP encryption, you should upgrade your router to something more secure. However it may be possible to connect your Photon with some difficulty by following the [WEP configuration instructions](http://rickkas7.github.io/wep/). 16 | 17 | And the less common situations: 18 | 19 | - If you get fast blinking green, especially in classroom and hack-a-thon type situations, it is possible that your network has run out of DHCP IP addresses. 20 | 21 | - If your Wi-Fi network does not support DHCP, and only uses static IP addresses, it is possible, though somewhat difficult, to set up a Photon. You will need to flash a program like this by USB to set the IP address: 22 | 23 | ``` 24 | #include "Particle.h" 25 | 26 | SYSTEM_THREAD(ENABLED); 27 | 28 | void setup() { 29 | Serial.begin(9600); 30 | 31 | IPAddress myAddress(192,168,1,33); 32 | IPAddress netmask(255,255,255,0); 33 | IPAddress gateway(192,168,1,1); 34 | IPAddress dns(192,168,1,1); 35 | WiFi.setStaticIP(myAddress, netmask, gateway, dns); 36 | 37 | // now let's use the configured IP 38 | WiFi.useStaticIP(); 39 | 40 | // To switch back to dynamic IP, use: 41 | // WiFi.useDynamicIP(); 42 | 43 | // Turn on the D7 LED so we know the operation completed 44 | pinMode(D7, OUTPUT); 45 | digitalWrite(D7, HIGH); 46 | } 47 | 48 | void loop() { 49 | } 50 | ``` 51 | 52 | - If the Wi-Fi network restricts access to known device Ethernet MAC addresses, you'll need to determine the MAC address and give it to the network administrator. Put the Photon in listening mode (blinking dark blue) by holding down the SETUP button, then use the Particle CLI command: 53 | 54 | ``` 55 | particle serial mac 56 | ``` 57 | 58 | - If the Photon has ever been used with an external antenna, it may still be set to use the external antenna only. It won't fall back to the internal antenna, even if there is no signal, when using the ANT_EXTERNAL mode. The following program resets the antenna. 59 | 60 | ``` 61 | #include "Particle.h" 62 | 63 | STARTUP(WiFi.selectAntenna(ANT_INTERNAL)); 64 | 65 | void setup() { 66 | // So you can tell the operations have completed 67 | pinMode(D7, OUTPUT); 68 | digitalWrite(D7, HIGH); 69 | } 70 | 71 | void loop() { 72 | } 73 | ``` 74 | 75 | 76 | -------------------------------------------------------------------------------- /breathing-green/README.md: -------------------------------------------------------------------------------- 1 | # Particle Breathing Green Tips 2 | 3 | [Breathing green](https://docs.particle.io/guide/getting-started/modes/photon/#cloud-not-connected) mode can be confusing to new Particle programmers but fortunately it's usually easy to recover from. 4 | 5 | ## I can't flash my Photon anymore 6 | 7 | Breathing green means that Wi-Fi is on, but you're not connected to the Particle cloud. Because of this, you cannot flash your Photon from the cloud. That includes Particle Build (Web IDE), Particle Dev (Atom IDE) and Particle CLI cloud-based flashing commands. 8 | 9 | Fortunately, you can usually get around this by entering [safe mode](https://docs.particle.io/guide/getting-started/modes/photon/#safe-mode), breathing magenta. 10 | 11 | Hold down RESET and SETUP (or MODE), release RESET and continue to hold down SETUP/MODE until the Photon/Electron blinks magenta, then release SETUP/MODE. The device will then go through the normal sequence of colors: blinking green, blinking cyan, fast blinking cyan, then breathing magenta. Once breathing magenta, you should be able to OTA flash again. 12 | 13 | But to get rid of the breathing green, you'll probably need to make some changes to your code. 14 | 15 | ## Do not unclaim your device 16 | 17 | This rarely if ever fixes anything, and it sometimes can make things much worse. Resist the urge to do this. It never fixes a blinking green problem. 18 | 19 | ## Cause 1: Blocking the loop 20 | 21 | In this simple program, you'll breathe cyan, then about 10 seconds later, you'll go to breathing green. Why? You've blocked the loop from returning, and in the default threading and system mode, that stops the cloud from being processed, which causes breathing green. 22 | 23 | Don't do this: 24 | 25 | ``` 26 | void setup() { 27 | } 28 | 29 | void loop() { 30 | 31 | // Don't do this: preventing loop from returning will cause breathing green 32 | while(true) { 33 | 34 | } 35 | } 36 | ``` 37 | 38 | Of course your code probably has a more subtle bug than that. For example, if you have a function that's called from setup or loop that never returns, that can cause problems. 39 | 40 | Some libraries that deal with sensor hardware might behave strangely when the hardware is not available, which could cause a call to block forever as well. 41 | 42 | ## Solution 1: Add some Particle.process() calls 43 | 44 | One way to solve this is to sprinkle Particle.process() calls in code that blocks. You might do something like this: 45 | 46 | ``` 47 | void waitForSwitch() { 48 | while(digitalRead(D7) == HIGH) { 49 | // Without the following line, you'd go into breathing green 50 | Particle.process(); 51 | } 52 | } 53 | ``` 54 | 55 | In general it's better to structure your code so it always returns from loop(), but if that's not a viable solution, you can sprinkle some Particle.process() calls in your code. 56 | 57 | ## Solution 2: Enable SYSTEM_THREAD 58 | 59 | The other solution is to use [SYSTEM_THREAD](https://docs.particle.io/reference/firmware/#system-thread) mode. 60 | 61 | ``` 62 | SYSTEM_THREAD(ENABLED); 63 | ``` 64 | 65 | You insert this at the top of your source file. What it does is run the cloud processing in a separate system thread, so if you block your loop, the cloud will still be serviced and you will stay in breathing cyan instead of going to breathing green. 66 | 67 | The only thing to be careful is that when you do this, your loop code will run before connected to the cloud. One solution is to add this in your setup() code, before you do any Particle.publish calls: 68 | 69 | ``` 70 | waitUntil(Particle.connected); 71 | ``` 72 | 73 | You might also do something like this in loop(): 74 | 75 | ``` 76 | if (Particle.connected()) { 77 | Particle.publish("myEvent", PRIVATE); 78 | } 79 | ``` 80 | 81 | 82 | ## Side note: Wi-Fi only mode 83 | 84 | While all of the causes above were unintentionally causing breathing green, you can also do it on purpose. Using the [SEMI_AUTOMATIC or MANUAL system mode](https://docs.particle.io/reference/firmware/#semi-automatic-mode) and only bringing up Wi-Fi and not the cloud will cause intentional breathing green. You would do this if you're sending data to a local server and not using the cloud at all, for example. 85 | 86 | -------------------------------------------------------------------------------- /classroom-tips/README.md: -------------------------------------------------------------------------------- 1 | # Particle Photon tips for classrooms 2 | 3 | **Some useful tips for using the Particle Photon in classrooms, hackathons, etc.** 4 | 5 | ## Option 1: Self-configuration 6 | 7 | With the self-configuration option, students: 8 | 9 | - Create their own Particle accounts, either with school or personal email. 10 | - Set up Wi-Fi and claim the Photon to their account with their personal phones. 11 | 12 | This method is allows factory-fresh Photons to be unboxed and used immediately, however there are some caveats: 13 | 14 | - Some phones have difficulties setting up a Photon. 15 | - This process is hard to debug since there isn't much feedback if something goes wrong. 16 | - Wi-Fi based configuration always uses Wi-Fi channel 1 when in listening mode (blinking blue). With a large number of Photons simultaneously using the same Wi-Fi channel interference can result. It may be helpful to stagger turning on the Photons. 17 | 18 | On the narrower side of the Photon box is a barcode and serial number that looks like: PHHMAB804PAKLJZ 19 | 20 | The Wi-Fi network to configure that Photon is Photon-KLJZ. The last 4 characters of the serial number are the suffix on the Wi-Fi configuration network name. That's how you can tell which network to use. 21 | 22 | For older Photons, the serial number looks like PH-160329-KVXY-0 and the network is Photon-KVXY. 23 | 24 | ### Setting up an instructor station 25 | 26 | It's a good idea to set up an instructor station that has the [Particle CLI](https://docs.particle.io/guide/tools-and-features/cli/photon/) installed. This can be used to help out students who don't have a phone or whose phone does not work, and also troubleshoot some more difficult issues. 27 | 28 | 29 | If the student is unable to claim the device, these commands usually solve the problem: 30 | 31 | ``` 32 | particle identify 33 | particle serial wifi 34 | ``` 35 | 36 | The `particle identify` command prints out the device ID of the Photon. This is important because it will be necessary to for the student to enter this to claim the device. 37 | 38 | The `particle serial wifi` command sets up the Wi-Fi network but does not claim the device, allowing the student to claim the device on their own account. 39 | 40 | If the Photon gets all the way to breathing cyan, then the student can log into https://build.particle.io and uses the Devices icon (circle with 4 lines) and uses the **Add Device** option, entering the device ID for the Photon. 41 | 42 | 43 | ## Option 2: Preconfiguring Wi-Fi 44 | 45 | Another option is to set up the Photon Wi-Fi on each Photon ahead of time. This simplifies setup for the student: 46 | 47 | - Create their own Particle accounts, either with school or personal email, typically from a web browser. 48 | - Claim the device to their Particle account using Particle Build (Web IDE) or Particle Dev (Atom IDE), whatever you are using for programming. 49 | - No phone is needed for setup. 50 | 51 | ### Student process 52 | 53 | The student: 54 | 55 | - Receives a Photon with the Wi-Fi configured, so plugging it in should go through the normal sequence of white, blinking green, blinking cyan (light blue), fast blinking cyan, and breathing cyan. 56 | 57 | - Also receives the device ID for the Photon, a 24-character combination of numbers and the letters a-f. Note that the letters should always be entered in lower case. 58 | 59 | - Goes to https://build.particle.io and logs in or creates an Particle account. 60 | 61 | - Uses the Devices icon (circle with 4 lines) and uses the **Add Device** option, entering the device ID for the Photon. 62 | 63 | ### Pre-configuration process 64 | 65 | The easiest way to pre-configure Wi-Fi is using the Particle CLI. With the Photon in listening mode (blinking blue), use the commands: 66 | 67 | ``` 68 | particle identify 69 | particle serial wifi 70 | ``` 71 | 72 | The `particle identify` command prints out the device ID of the Photon. This is important because it will be necessary to for the student to enter this to claim the device. 73 | 74 | The `particle serial wifi` command sets up the Wi-Fi network but does not claim the device, which is perfect for this application. 75 | 76 | 77 | ## Debugging tips 78 | 79 | The normal sequence of the status LED is: 80 | 81 | - White 82 | - Blinking green 83 | - Blinking cyan 84 | - Fast blinking cyan 85 | - Breathing cyan 86 | 87 | The point where it stops can be helpful in determining what went wrong. 88 | 89 | ### Stops at blinking green 90 | 91 | If some Photons cannot get past this state: 92 | 93 | - If your network has run out of available IP addresses in the DHCP address pool, the Photon will stop at blinking green. The network administrator can usually check this. 94 | 95 | - If your network restricts access to certain devices by Ethernet MAC address, you will need to make sure the affected Photon is allowed. Your network administrator will tell if you if this is necessary. You can find your MAC address using the instructions [here](https://github.com/rickkas7/particle_notes/tree/master/blinking-green). This is not common. 96 | 97 | If no Photons can get past this state: 98 | 99 | - If you are using a corporate or school network that uses WPA2 Enterprise, the Photon cannot be used at this time. If you require both a username and a password, or see a mention of 802.1(x), or RADIUS you're using WPA2 Enterprise. 100 | 101 | - If you are using a network that takes you to a web page where you need to either sign in or agree to terms and service when you first connect, using the Photon directly will be difficult or impossible. This is the case in some hotels and public Wi-Fi networks and is often referred to as Captive Portal. 102 | 103 | - If your Wi-Fi network uses 5 GHz only, instead of the more common 2.4 GHz, the Photon cannot be used. The Wi-Fi radio is only compatible with 2.4 GHz networks. 104 | 105 | ### Blinking cyan or fast blinking cyan 106 | 107 | - This can sometimes indicate a problem with DNS or a Firewall. Using the diagnostic program in the following section will show when this is occurring. 108 | 109 | - Photons running system firmware 0.6.0 and later require working DNS (domain name service) to connect to the cloud. If your DHCP server is returning an invalid DNS server, or the DNS server is not functioning correctly, the Photon may not be able to connect to the cloud. 110 | 111 | - The firewall must allow outbound TCP access to port 5683 (CoAP) on device.spark.io (currently 54.173.1.44 but the address may change) to allow Photons to connect to the cloud. 112 | 113 | - It should also allow outbound https (port 443) to build.particle.io, console.particle.io and api.particle.io for building and using the API. 114 | 115 | ### Fast blinking cyan with red or orange blinks 116 | 117 | This sometimes indicates a problem with the server or device keys. 118 | 119 | Put the Photon into Listening mode (blinking blue) by holding down SETUP until it blinks blue. Then issue the CLI command: 120 | 121 | ``` 122 | particle identify 123 | ``` 124 | 125 | Save the Device ID; you’ll need it later. 126 | 127 | Then put the Photon in DFU mode by holding down both the RESET and SETUP buttons, releasing RESET and continuing to hold down SETUP until it blinks yellow and issue the commands below, in order. 128 | 129 | ``` 130 | particle keys server 131 | particle keys doctor YOUR_DEVICE_ID 132 | ``` 133 | 134 | ## Running the cloud debug program 135 | 136 | Sometimes it's not possible to tell what's going wrong just by monitoring the lights. Flashing this firmware to the device will print out additional debugging information. The log file can be sent to [Particle support](http://support.particle.io) for further investigation. 137 | 138 | [https://github.com/rickkas7/photon-clouddebug](https://github.com/rickkas7/photon-clouddebug) 139 | 140 | 141 | ## Recycling Photons 142 | 143 | If you reuse the Photons with another class, it will be necessary to do some work to clean them up. You can save a great deal of effort by requesting that the departing students unclaim the devices from their accounts. It's possible to recover if they don't, but it adds several steps to the process. 144 | 145 | Complete instructions are here: [https://github.com/rickkas7/photonreset](https://github.com/rickkas7/photonreset). 146 | 147 | -------------------------------------------------------------------------------- /create-product-webhook/README.md: -------------------------------------------------------------------------------- 1 | # Creating a product webhook 2 | 3 | The [Particle CLI](https://docs.particle.io/guide/tools-and-features/cli) is my preferred way to create webhooks because I prefer editing a JSON file over using the web-based UI in the [console](https://console.particle.io). 4 | 5 | By the way, if you're used to using the web-based UI, my [webhook tutorial](https://github.com/rickkas7/particle-webhooks) includes information on how to map from the fields in the web user interface to the JSON configuration. 6 | 7 | But one major problem is that the particle CLI does not allow you to create product webhooks. This will be fixed at some point in the future, but for now, here's a workaround. 8 | 9 | **This was a very quickly implemented workaround. It may have bugs.** 10 | 11 | You'll need to have curl installed to use this technique. It's usually built-in for Mac and Linux, but for Windows you'll [need to install it](https://docs.particle.io/faq/particle-tools/installing-curl/). 12 | 13 | ## Authentication 14 | 15 | One issue when working with products is that you can't use a standard authentication token, like the one copied out of [Particle build](https://build.particle.io). 16 | 17 | At [console.particle.io](https://console.particle.io) select your product, then the Authentication icon (fingerprint). Create a new OAuth client, two-legged (server) with no restrictions (full permissions). Save the client ID and secret. Make sure you keep the secret secret. Also, this is not an authentication token. 18 | 19 | ![Console](console.png) 20 | 21 | ``` 22 | curl https://api.particle.io/oauth/token -u "tempmon06-3459:460edfd8d70742dd1f1e75c3d5cac5973351465d" -d grant_type=client_credentials 23 | ``` 24 | 25 | Note that: 26 | 27 | - tempmon06-3459 is what's in the ClientID column in the list of authentications. 28 | - 460edfd8d70742dd1f1e75c3d5cac5973351465d is your secret key. 29 | 30 | A successful response to that includes the access token in the access_token parameter. For example: 31 | 32 | ``` 33 | { 34 | "token_type": "bearer", 35 | "access_token": "5724113917ac1e1cbf80cae2e24dd27c56245bdb", 36 | "expires_in": 7776000, 37 | "refresh_token": "7ff08565378780581aa27eeb4eb92a4e4dbcc3a5" 38 | } 39 | ``` 40 | 41 | You can test it out using a command like: 42 | 43 | ``` 44 | curl https://api.particle.io/v1/products/tempmon-v100?access_token=5724113917ac1e1cbf80cae2e24dd27c56245bdb 45 | ``` 46 | 47 | Where: 48 | 49 | - tempmon-v100 is your product slug. It's what shows up in the URL bar when you're viewing your product. 50 | - 5724113917ac1e1cbf80cae2e24dd27c56245bdb is replaced by your access token you just created 51 | 52 | Or, get an actual list of your product webhooks: 53 | 54 | ``` 55 | curl https://api.particle.io/v1/products/tempmon-v100/webhooks?access_token=5724113917ac1e1cbf80cae2e24dd27c56245bdb 56 | ``` 57 | 58 | ## Creating a webhook 59 | 60 | As it turns out, while the API for creating a webhook is simple, it requires converting the hook JSON file into form URL encoded, which is not a feature built into curl. 61 | 62 | To get around this, I wrote a very short node.js script to do it. 63 | 64 | **I wrote this very quickly. There may be bugs.** 65 | 66 | ### Initial setup 67 | 68 | - Download the [prodhook.js](https://raw.githubusercontent.com/rickkas7/particle_notes/master/create-product-webhook/prodhook.js) file into a directory. 69 | 70 | - From the command line, in the directory with prodhook.js, install its dependencies: 71 | 72 | ``` 73 | npm install yargs request 74 | ``` 75 | 76 | ### Update the accessToken 77 | 78 | You can either modify prodhook.js and paste in your access token retrieved above, or you can pass it on the command line. 79 | 80 | - Editing prodhook.js: 81 | 82 | ``` 83 | // You can paste your access token here for convenience, or use the --accessToken=xxxxx option 84 | var accessToken = '5724113917ac1e1cbf80cae2e24dd27c56245bdb'; 85 | 86 | // And your productSlug, or use the --productSlug=xxx option 87 | var productSlug = 'tempmon-v100'; 88 | ``` 89 | 90 | - Command Line: 91 | 92 | ``` 93 | node prodhook.js list --accessToken=5724113917ac1e1cbf80cae2e24dd27c56245bdb --productSlug=tempmon-v100 94 | ``` 95 | 96 | ### Listing webhooks 97 | 98 | To list the product webhooks, use the command: 99 | 100 | ``` 101 | node prodhook.js list 102 | ``` 103 | 104 | Or: 105 | 106 | ``` 107 | node prodhook.js list --accessToken=5724113917ac1e1cbf80cae2e24dd27c56245bdb --productSlug=tempmon-v100 108 | ``` 109 | 110 | ### Creating webhooks 111 | 112 | To create a product webhook, create a hook JSON file, and use a command like: 113 | 114 | ``` 115 | node prodhook.js create hook2.json 116 | ``` 117 | 118 | Or: 119 | 120 | ``` 121 | node prodhook.js create hook2.json --accessToken=5724113917ac1e1cbf80cae2e24dd27c56245bdb --productSlug=tempmon-v100 122 | ``` 123 | 124 | 125 | ### Deleting webhooks 126 | 127 | To delete a webhook, use the ID you got from list or create. 128 | 129 | ``` 130 | node prodhook.js delete 5877a29f6bde6c72077c23ef 131 | ``` 132 | 133 | Or: 134 | 135 | ``` 136 | node prodhook.js delete 5877a29f6bde6c72077c23ef --accessToken=5724113917ac1e1cbf80cae2e24dd27c56245bdb --productSlug=tempmon-v100 137 | ``` 138 | 139 | -------------------------------------------------------------------------------- /create-product-webhook/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/create-product-webhook/console.png -------------------------------------------------------------------------------- /create-product-webhook/prodhook.js: -------------------------------------------------------------------------------- 1 | // Run this like: 2 | // node prodhook.js 3 | // 4 | // Requires the following additional packages. From the directory containing prodhook.js, run: 5 | // npm install yargs request 6 | 7 | // You can paste your access token here for convenience, or use the --accessToken=xxxxx option 8 | var accessToken = ''; 9 | 10 | // And your productSlug, or use the --productSlug=xxx option 11 | var productSlug = ''; 12 | 13 | 14 | // https://github.com/request/request 15 | var request = require('request'); 16 | 17 | // yargs argument parser (successor to optimist) 18 | // https://www.npmjs.com/package/yargs 19 | var argv = require('yargs') 20 | .usage('Usage: $0 [options]') 21 | .demandCommand(1) 22 | .command('list', 'list product webhooks') 23 | .command('create', 'create a product webhook') 24 | .command('delete', 'delete a product webhook') 25 | .help('h') 26 | .alias('h', 'help') 27 | .argv; 28 | 29 | // Built-in node class 30 | var fs = require('fs'); 31 | 32 | if (argv.accessToken) { 33 | accessToken = argv.accessToken; 34 | } 35 | if (accessToken == '') { 36 | console.error("error: no accessToken specified"); 37 | process.exit(1); 38 | } 39 | if (argv.productSlug) { 40 | productSlug = argv.productSlug; 41 | } 42 | if (productSlug == '') { 43 | console.error("error: no productSlug specified"); 44 | process.exit(1); 45 | } 46 | 47 | var options = { 48 | url: 'https://api.particle.io/v1/products/' + productSlug + '/webhooks', 49 | headers: { 50 | 'Authorization' : 'Authorization: Bearer ' + accessToken 51 | } 52 | }; 53 | 54 | 55 | if (argv._[0] == 'list') { 56 | request(options, function (error, response, body) { 57 | console.log(body); 58 | }) 59 | } 60 | else 61 | if (argv._[0] == 'create') { 62 | if (argv._.length == 1) { 63 | console.error("error: hook json file required"); 64 | process.exit(1); 65 | } 66 | 67 | var hookStr = fs.readFileSync(argv._[1], 'utf8'); 68 | 69 | options.method = 'POST'; 70 | options.form = JSON.parse(hookStr); 71 | 72 | request(options, function (error, response, body) { 73 | console.log(body); 74 | }) 75 | } 76 | else 77 | if (argv._[0] == 'delete') { 78 | if (argv._.length == 1) { 79 | console.error("error: webhook id required"); 80 | process.exit(1); 81 | } 82 | 83 | options.method = 'DELETE'; 84 | options.url = options.url + '/' + argv._[1]; 85 | 86 | request(options, function (error, response, body) { 87 | console.log(body); 88 | }) 89 | } 90 | else { 91 | console.error("error: unknown command"); 92 | process.exit(1); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /debugging-windows-7-drivers/1-device-serial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/1-device-serial.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/10-electron-serial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/10-electron-serial.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/2-serial-driver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/2-serial-driver.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/3-devmgmt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/3-devmgmt.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/4-show-hidden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/4-show-hidden.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/5-photon-hidden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/5-photon-hidden.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/6-extract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/6-extract.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/7-browse-for-driver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/7-browse-for-driver.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/8-select-driver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/8-select-driver.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/9-installer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/debugging-windows-7-drivers/9-installer.png -------------------------------------------------------------------------------- /debugging-windows-7-drivers/README.md: -------------------------------------------------------------------------------- 1 | # Debugging Windows 7 Driver Issues 2 | 3 | This guide has some tips for debugging driver issues with Windows 7. There will be a separate guide for Windows 10, which is different enough that it warrants a separate guide. 4 | 5 | ## Getting started 6 | 7 | One common bit of confusion is that there are two different drivers used, one for normal operating mode with serial enabled and listening mode (blinking dark blue) that maps to a COM port, and a separate set of drivers for use in DFU mode (blinking yellow). It is possible for one set of drivers to work and not the other. 8 | 9 | ### Windows Device Manager 10 | 11 | You'll be using the Windows Device Manager for several steps. From the **Start** menu, select **Control Panel**. The default is **View by: Category** so select **Hardware and Sound** then select **Device Manager**. 12 | 13 | 14 | ## Serial drivers 15 | 16 | Ideally, when you plug in the Photon it will install its device driver, and then you'll see something like **Photon (COM3)** in the **Ports (COM & LPT)** section. 17 | 18 | ![Device Manager Serial](1-device-serial.png) 19 | 20 | If you right click on the **Photon** item and select **Properties** then click on the **Driver** tab, it should look like this: 21 | 22 | ![Serial Driver Properties](2-serial-driver.png) 23 | 24 | If you have an Electron, it might show up as something like **Electron Serial (COM4)**. The driver settings should be these same as the Photon. 25 | 26 | ![Device Manager Serial](10-electron-serial.png) 27 | 28 | 29 | ### Removing old drivers 30 | 31 | Once in a while you'll get stuck with a hidden old driver, and the solution is to remove all of them. 32 | 33 | - Unplug all Particle Photon/P1/Electron/Core devices. 34 | - Right click on **Command Prompt** and select **Run as Administrator**. 35 | - Enter the commands: 36 | 37 | ``` 38 | set devmgr_show_nonpresent_devices=1 39 | devmgmt.msc 40 | ``` 41 | 42 | ![Running devmgmt](3-devmgmt.png) 43 | 44 | - Open the Device Manager. Select **Show hidden devices** from the **View menu**. 45 | 46 | ![Show Hidden Devices](4-show-hidden.png) 47 | 48 | - Now the Photon or Electron should appear in the **Ports (COM & LPT)** section. The COM port number may be different, and there may be more than one. 49 | 50 | ![Hidden Photon](5-photon-hidden.png) 51 | 52 | - Select the Photon or Electron item and hit the **Delete** key, or right-click and select **Uninstall**. The item will disappear. Repeat for all of the Photon or Electron items. 53 | 54 | - Close the Device Manager and then plug the Photon or Electron back in and it should automatically reinstall the drivers, hopefully correctly. 55 | 56 | For more information on this technique, see [this post](https://community.particle.io/t/windows7-photon-driver-installation-access-is-denied-solved/25799/6). 57 | 58 | ### Manually installing serial drivers (0.6.0 and later) 59 | 60 | If your Photon/P1/Electron/Core is running system firmware 0.6.0 or later, the serial driver situation can be a little easier. Instead of manually uninstalling and reinstalling the drivers, you can simply run the [Particle driver installer](https://github.com/spark/windows-device-drivers/releases/download/v6.1.0.51/particle_drivers_6.1.0.51.exe). 61 | 62 | ![Driver Installer](9-installer.png) 63 | 64 | For more information about what it does you can check the [Github repository](https://github.com/spark/windows-device-drivers/) for it. 65 | 66 | 67 | ### Manually installing serial drivers (before 0.6.0) 68 | 69 | If you have a **Photon** device under **Ports (COM & LPT)** in the Device Manager, you can fix the driver using this technique. 70 | 71 | - [Download the drivers](https://s3.amazonaws.com/spark-website/Spark.zip) from Particle and save to your Downloads folder. 72 | 73 | - Open your **Downloads** folder, right-click on **Spark.zip** and select **Extract All...** 74 | 75 | ![Extract All](6-extract.png) 76 | 77 | - Open the **Device Manager** and select **Ports (COM & LPT)**. Right click on **Photon** and select **Update Driver Software**. 78 | 79 | - Select **Browse my computer for driver software** 80 | 81 | ![Browse for driver](7-browse-for-driver.png) 82 | 83 | - Select the driver you just downloaded, for example: **Downloads** then **Spark** then **Particle_Windows_Serial_drivers**. 84 | 85 | ![Select driver](8-select-driver.png) 86 | 87 | - The driver should be installed. 88 | 89 | - If you use [Zadig](http://zadig.akeo.ie) to check the drivers, it should show up as **Photon Serial** and be mapped to usbser (v.6.1.0.0) when using Windows 7 (actually, any version prior to 10). 90 | 91 | For more information on this technique, see [this post](https://community.particle.io/t/installing-the-usb-driver-on-windows-serial-debugging/882). Note that you should download the driver above, not the one originally linked to in the post. 92 | 93 | 94 | ## DFU drivers 95 | 96 | The DFU drivers are only used when the Photon/P1/Electron/Core is blinking yellow. You typically enter DFU mode by holding down RESET and SETUP, releasing RESET and continuing to hold down SETUP while it blinks magenta until it blinks yellow, then release. (For the Electron and Core, the button is labeled MODE instead of SETUP.) 97 | 98 | The easiest way to install the DFU drivers is to install the Particle CLI, which should install the drivers for you. 99 | 100 | If you are still having trouble using DFU, there are more tips in the [Installing DFU-util FAQ](https://docs.particle.io/faq/particle-tools/installing-dfu-util/). 101 | 102 | -------------------------------------------------------------------------------- /disabling-dfu-mode/README.md: -------------------------------------------------------------------------------- 1 | # Disabling DFU mode 2 | 3 | It is possible to disable DFU mode access by USB by modifying the bootloader. This may provide some additional security, though without also disabling JTAG data can still be read out of the device. 4 | 5 | Also it's hard to prevent future system firmware upgrades from removing your custom bootloader. 6 | 7 | And it will make it very difficult to recover from some situations like bad device keys. 8 | 9 | However, here's what you have to do. 10 | 11 | ## You will need 12 | 13 | - A working [gcc-arm local build chain](https://docs.particle.io/faq/particle-tools/local-build/). You can't use the cloud compilers. 14 | - [Firmware source](https://github.com/particle-iot/firmware/) for the correct release. 15 | - Optional: A JTAG/SWD programmer in case you flash a bad bootloader, as it's the only way to recover from that. 16 | 17 | The bootloader must be the appropriate one for your system firmware version. The bootloader is not changed with every system firmware update, but you do need to make sure you have the right one. [This table](https://github.com/spark/firmware/blob/develop/system/system-versions.md) shows all of the versions. 18 | 19 | If, for example, you're using system firmware 0.7.0 you'd check out the branch `release/v0.7.0`. 20 | 21 | ## Building the bootloader 22 | 23 | To build the bootloader, you typically do something like: 24 | 25 | ``` 26 | cd firmware/bootloader 27 | make all PLATFORM=photon 28 | ``` 29 | 30 | Other common platforms are electron and p1. 31 | 32 | To test it out, put the device in listening mode (blinking dark blue) and: 33 | 34 | ``` 35 | particle flash --serial ../build/target/bootloader/platform-6-lto/bootloader.bin 36 | ``` 37 | 38 | The platform directory will be different for other platforms (Electron = 10, P1 = 8). 39 | 40 | ## Disabling DFU mode 41 | 42 | To actually disable DFU mode, edit src/main.c. Comment out this line: 43 | 44 | ``` 45 | HAL_DFU_USB_Init(); 46 | ``` 47 | 48 | In 0.7.0, it's line 458. 49 | 50 | Then build as you did above. You'll still go into blinking yellow, but the DFU device won't exist. For example, if you do: 51 | 52 | ``` 53 | dfu-util -l 54 | ``` 55 | 56 | the device won't show up now. 57 | 58 | ## Listening mode 59 | 60 | Of course this will also point out that you'll need to disable listening mode as well, otherwise the bootloader can be reprogrammed that way. You can do that from your user firmware by detecting that you're going into listening mode, then exit listening mode. 61 | 62 | However, that wouldn't prevent going into listening mode from safe mode. 63 | 64 | Anyway, you can see that this starts down a horrible rabbit hole of mitigations, so maybe this isn't a great idea, after all. 65 | -------------------------------------------------------------------------------- /electron-3rdparty-sims/01electronwithsim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/electron-3rdparty-sims/01electronwithsim.png -------------------------------------------------------------------------------- /electron-3rdparty-sims/02setup3rdparty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/electron-3rdparty-sims/02setup3rdparty.png -------------------------------------------------------------------------------- /electron-3rdparty-sims/03devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/electron-3rdparty-sims/03devices.png -------------------------------------------------------------------------------- /electron-shadow-customers/README.md: -------------------------------------------------------------------------------- 1 | # Electron shadow customers 2 | 3 | Often Electron product creators claim all of their devices to a single account controlled by the product creator. This is simple and works well, however it is possible to use Electrons with shadow customers like is common with Photon/P1 products. 4 | 5 | If you've already studied the [manual Photon claiming](https://github.com/rickkas7/particle_notes/tree/master/manual-photon-claiming) instructions, you'll notice that this really the same up to the *Create a product claim code* step in that document. You can jump forward to that section now, if desired. 6 | 7 | ### Creating an OAuth client 8 | 9 | In order to use the product APIs, you need a product access token. Creating one is a two-step process. The first part is to create an OAuth client. 10 | 11 | - Open your product in the [console](https://console.particle.io) 12 | - Open the **Authentication** tab. 13 | - Click **New Client**. 14 | 15 | ![Create Client](images/create_client.png) 16 | 17 | You will want to create **Two-legged Auth (Server)** client. In the next screen, you will get a token. Copy and paste this as you can't get it back again. It's also important to keep this a secret. And, it's not your product access token. 18 | 19 | ![Authentication List](images/auth_list.png) 20 | 21 | In the next steps you'll need a few things: 22 | 23 | - The **Name** field matches the name of the product (ElectronTest1) 24 | - The OAuth **Client ID** field will be needed to make API calls (test1-7141) 25 | - The OAuth client secret we got when creating a new client. In the examples below, `8804b8cbca56e71b275fb9ebd10cada2bb515e9a` is the token we got. 26 | 27 | ### Create a product bearer token 28 | 29 | In order to use the some of the product APIs you need a product bearer token. Here's a command in curl to create one: 30 | 31 | ``` 32 | curl https://api.particle.io/oauth/token -u "test1-7141:8804b8cbca56e71b275fb9ebd10cada2bb515e9a" -d grant_type=client_credentials 33 | ``` 34 | 35 | - `test1-7141 ` is the OAuth client ID (two-legged server type) 36 | - `8804b8cbca56e71b275fb9ebd10cada2bb515e9a ` is the OAuth client secret 37 | 38 | Note that the username and password passed in the -u option are the client ID created above and the access token for that client. 39 | 40 | That call will return something like this: 41 | 42 | ``` 43 | { 44 | "token_type":"bearer", 45 | "access_token":"585f9e53abb125535c2227d298369b6a77c128cf", 46 | "expires_in"7776000, 47 | "refresh_token":"32a2f31809cf6eff957d593c187f88075e9dadd4" 48 | } 49 | ``` 50 | 51 | That access_token `585f9e53abb125535c2227d298369b6a77c128cf ` is the one you need! 52 | 53 | The reason for all of this is that the client token needs to be kept safe because it has the ability to create new tokens. The bearer token you use to authenticate individual requests has a shorter life and is more "disposable" in case it gets into the wrong hands. 54 | 55 | ### Product ID or Slug 56 | 57 | Most of the product APIs include `:productOdOrSlug` in the URL. 58 | 59 | Your product ID is a number, located next to the key on the top of your priduct window. It's 6287 in the screenshot below. 60 | 61 | You can also use the string in the URL. In this example, its **electrontest1-v10**. 62 | 63 | ![Product ID or Slug](images/product_id_or_slug.png) 64 | 65 | Armed with these two things, you can now make product API calls! 66 | 67 | Get information about your product: 68 | 69 | ``` 70 | curl https://api.particle.io/v1/products/6287?access_token=585f9e53abb125535c2227d298369b6a77c128cf 71 | ``` 72 | 73 | Or using the slug: 74 | 75 | ``` 76 | curl https://api.particle.io/v1/products/electrontest1-v10?access_token=585f9e53abb125535c2227d298369b6a77c128cf 77 | ``` 78 | 79 | ### Add the device to the product 80 | 81 | It's not obvious from the documentation, but you have to [add the device ID to the product](https://docs.particle.io/reference/api/#import-devices-into-product) before it can be claimed using two-legged auth. 82 | 83 | Here's the command I used: 84 | 85 | ``` 86 | curl -X POST https://api.particle.io/v1/products/6287/devices -d access_token=585f9e53abb125535c2227d298369b6a77c128cf -d id=b1eeaa1f7cdc4eda5d6aa375 87 | ``` 88 | 89 | ``` 90 | {"updated":1,"nonmemberDeviceIds":[],"invalidDeviceIds":[]} 91 | ``` 92 | 93 | - `6287` is the product ID 94 | - access_token is the product bearer token generated above 95 | - id is the device ID to add 96 | 97 | You can also do this from a file, and also using the console. Imagine you are making a product based on the Electron. You'd buy trays of Electron and import those device IDs into the console for your product. This is what prevents a user from turning a generic Electron into your product. 98 | 99 | ## Creating a customer 100 | 101 | ``` 102 | curl -X POST https://api.particle.io/v1/products/6287/customers -u "test1-7141:8804b8cbca56e71b275fb9ebd10cada2bb515e9a" -d email=customer30@company.com -d no_password=true 103 | ``` 104 | 105 | ``` 106 | {"token_type":"bearer","access_token":"f9e01db22a020a35be7e6870093155b2a9675683","expires_in":7776000,"refresh_token":"6d3680db6ffcda58ef85ba24dbf11e7105a9ad2e","scope":"customer=customer30@company.com"} 107 | ``` 108 | 109 | - `6287` is the product ID 110 | - `test1-7141` is the OAuth client ID (two-legged server type) 111 | - `8804b8cbca56e71b275fb9ebd10cada2bb515e9a` is the OAuth client secret 112 | - `customer30@company.com` is the customer email 113 | - `no_password=true` says we're controlling the access tokens via two-legged auth; no login is allowed. 114 | 115 | If the customer already exists, you need to create a new client credentials token instead: 116 | 117 | ``` 118 | curl -X POST https://api.particle.io/oauth/token -u "test1-7141:8804b8cbca56e71b275fb9ebd10cada2bb515e9a" -d grant_type=client_credentials -d scope=customer=customer30@company.com 119 | ``` 120 | 121 | - `test1-7141` is the OAuth client ID (two-legged server type) 122 | - `8804b8cbca56e71b275fb9ebd10cada2bb515e9a` is the OAuth client secret 123 | - `customer30@company.com` is the customer email. Note that it really is `scope=customer=`*email*. 124 | 125 | Note that the email doesn't actually have to be your customer's email. If you are using simple auth and you want to use password recovery it does need to be a valid email, but for two-legged shadow customers it does not. 126 | 127 | One really confusing thing: When you create a customer it does not appear in your product's customer list! It exists, because if you try to create it again it won't let you, but it won't appear in the list until the customer has claimed a device. 128 | 129 | Also, you really need to use your OAuth client ID and secret in the basic auth (-u option). It won't create a token if you only use the product bearer token in a access_token. 130 | 131 | ### Claim the device to the customer 132 | 133 | It's not necessary to use a product endpoint to claim the device as claiming the device automatically will associate it with the product since the device ID has been added to the product. Also, the customer is associated with the product. 134 | 135 | ``` 136 | curl https://api.particle.io/v1/devices -d id=b1eeaa1f7cdc4eda5d6aa375 -d access_token=f9e01db22a020a35be7e6870093155b2a9675683 137 | ``` 138 | 139 | ``` 140 | {"customer_id":"5ad7788bdef33c046763d31c","product_id":6287,"updated_at":"2018-04-18T17:20:10.880Z","id":"b1eeaa1f7cdc4eda5d6aa375","connected":true,"ok":true} 141 | ``` 142 | 143 | The device now shows up with the owner as customer30@company.com! It also shows up in the customers tab. So far so good! 144 | 145 | ### Device Firmware 146 | 147 | For testing, I used this firmware. I used **Mark As Development Device** so I could just flash the firmware by USB and not have to upload the firmware binary. 148 | 149 | ``` 150 | #include "Particle.h" 151 | 152 | PRODUCT_ID(6287); 153 | PRODUCT_VERSION(1); 154 | 155 | void testEventHandler(const char *event, const char *data); 156 | 157 | int counter = 0; 158 | unsigned long lastIncrement = 0; 159 | 160 | void setup() { 161 | Serial.begin(9600); 162 | Particle.variable("counter", counter); 163 | Particle.subscribe("testEvent", testEventHandler, MY_DEVICES); 164 | } 165 | 166 | void loop() { 167 | 168 | if (millis() - lastIncrement > 1000) { 169 | lastIncrement = millis(); 170 | counter++; 171 | } 172 | } 173 | 174 | void testEventHandler(const char *event, const char *data) { 175 | Serial.printlnf("testEventHandler called %s", data); 176 | } 177 | 178 | ``` 179 | 180 | 181 | ### Interacting with the Electron as a customer 182 | 183 | The customer access token can be used in various API calls. For example, to list the customer's devices: 184 | 185 | ``` 186 | $ curl https://api.particle.io/v1/devices?access_token=f9e01db22a020a35be7e6870093155b2a9675683 187 | ``` 188 | - f9e01db22a020a35be7e6870093155b2a9675683 is a customer access token 189 | 190 | 191 | Get the value of a variable: 192 | 193 | ``` 194 | curl https://api.particle.io/v1/devices/b1eeaa1f7cdc4eda5d6aa375/counter?access_token=f9e01db22a020a35be7e6870093155b2a9675683 195 | ``` 196 | 197 | ``` 198 | {"cmd":"VarReturn","name":"counter","result":4307,"coreInfo":{"last_app":"","last_heard":"2018-04-18T17:28:02.716Z","connected":true,"last_handshake_at":"2018-04-18T17:27:20.401Z","deviceID":"b1eeaa1f7cdc4eda5d6aa375","product_id":6287} 199 | ``` 200 | 201 | - 3b0021001747353236343033 is the device ID to query 202 | - temp is the variable name 203 | - f9e01db22a020a35be7e6870093155b2a9675683 is a customer access token 204 | 205 | Publish a private event to the device: 206 | 207 | ``` 208 | curl https://api.particle.io/v1/devices/events \ 209 | -d "name=testEvent" \ 210 | -d "data=testing!" \ 211 | -d "private=true" \ 212 | -d "access_token=f9e01db22a020a35be7e6870093155b2a9675683" 213 | ``` 214 | 215 | And this appeared in the serial console: 216 | 217 | ``` 218 | testEventHandler called 219 | ``` 220 | -------------------------------------------------------------------------------- /electron-shadow-customers/images/auth_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/electron-shadow-customers/images/auth_list.png -------------------------------------------------------------------------------- /electron-shadow-customers/images/create_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/electron-shadow-customers/images/create_client.png -------------------------------------------------------------------------------- /electron-shadow-customers/images/product_id_or_slug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/electron-shadow-customers/images/product_id_or_slug.png -------------------------------------------------------------------------------- /erasing-configuration/README.md: -------------------------------------------------------------------------------- 1 | # How to erase the configuration data 2 | 3 | ## Back up data and private key 4 | 5 | It's possible to use the keys doctor to create a new set of keys, but this technique will save and restore your device private key instead. 6 | 7 | Photon: 8 | 9 | ``` 10 | dfu-util -d 2b04:d006 -a 0 -s 0x8004000:0x8000 -U config.bin 11 | particle keys save devicekeys.der 12 | ``` 13 | 14 | Electron: 15 | 16 | ``` 17 | dfu-util -d 2b04:d00a -a 0 -s 0x8004000:0x8000 -U config.bin 18 | particle keys save devicekeys.der 19 | ``` 20 | 21 | ## Reprogram 22 | 23 | Download the [empty.bin](https://raw.githubusercontent.com/rickkas7/particle_notes/master/erasing-configuration/empty.bin) file. Its a file 3618 0xff bytes in it, enough to overwrite the configuration. 24 | 25 | Photon: 26 | 27 | ``` 28 | dfu-util -d 2b04:d006 -a 1 -s 1 -D empty.bin 29 | ``` 30 | 31 | Electron: 32 | 33 | ``` 34 | dfu-util -d 2b04:d00a -a 1 -s 1 -D empty.bin 35 | ``` 36 | 37 | Note that this only overwrites the device configuration, not the WICED configuration, so your Wi-Fi settings will still be intact. 38 | 39 | ## Restore keys 40 | 41 | Photon: 42 | 43 | ``` 44 | particle keys server 45 | dfu-util -d 2b04:d006 -a 1 -i 0 -s 34 -D devicekeys.der 46 | ``` 47 | 48 | Electron: 49 | 50 | ``` 51 | particle keys server 52 | dfu-util -d 2b04:d00a -a 1 -i 0 -s 34 -D devicekeys.der 53 | ``` 54 | 55 | -------------------------------------------------------------------------------- /erasing-configuration/empty.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/erasing-configuration/empty.bin -------------------------------------------------------------------------------- /finding-device-id/android_serial1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/android_serial1.png -------------------------------------------------------------------------------- /finding-device-id/android_serial2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/android_serial2.png -------------------------------------------------------------------------------- /finding-device-id/devicemanager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/devicemanager.png -------------------------------------------------------------------------------- /finding-device-id/particledev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/particledev.png -------------------------------------------------------------------------------- /finding-device-id/putty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/putty.png -------------------------------------------------------------------------------- /finding-device-id/stlink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/stlink.png -------------------------------------------------------------------------------- /finding-device-id/usbserialnum-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/usbserialnum-linux.png -------------------------------------------------------------------------------- /finding-device-id/usbserialnum-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/usbserialnum-mac.png -------------------------------------------------------------------------------- /finding-device-id/usbserialnum-win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/finding-device-id/usbserialnum-win.png -------------------------------------------------------------------------------- /fixing-p1-keys-using-jtag/README.md: -------------------------------------------------------------------------------- 1 | # Fixing P1 keys using JTAG 2 | 3 | If you erase the configuration DCT sectors, you'll find that you can no longer connect to the cloud. For Photons, Electrons, and P1s with USB, the easiest way to fix this is to use: 4 | 5 | ``` 6 | particle keys server 7 | particle keys doctor YOUR_DEVICE_ID 8 | ``` 9 | 10 | These only work in DFU mode, so if you don't have a USB interface on your P1 board, you'll need to do it manually using JTAG/SWD. 11 | 12 | ## Using ST-LINK/V2 13 | 14 | In the example here, I've used an actual ST-LINK/V2 and their Windows software, but you can do this with an inexpensive SWD USB stick and openocd, if you prefer. 15 | 16 | Install the [ST-LINK/V2 software for Windows](http://www.st.com/en/development-tools/st-link-v2.html), if you have not already done so. The software is at the bottom of that page. 17 | 18 | The pins on the connector are numbered this way when you have the programmer positioned so the logo is upright and the notch is on the bottom of the 20-pin connector. 19 | 20 | ||||||||||| 21 | |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| 22 | | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 23 | | 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 24 | | | | | | notch | | | | | 25 | 26 | 27 | | Pin | Function | Color | P1 Pin | 28 | | --- | --- | --- | --- | 29 | | 1 | VCC | Red | 3V3 | 30 | | 4 | GND | Brown | GND | 31 | | 7 | SWDIO | Orange | D7 | 32 | | 9 | SWCLK | Yellow | D6 | 33 | 34 | ![st-link](stlink.jpg) 35 | 36 | With the ST-LINK, make sure you connect the VCC line to 3V3. It's used to detect the device voltage, and if you don't connect it, it does not work reliably. 37 | 38 | In the Settings, you will probably need to select: 39 | 40 | - **SWD** (you can use JTAG if you connect the rest of the pins) 41 | - **4.0 MHz** (though slower speeds will work too) 42 | - **Access Port 0** 43 | - **Hot Plug** mode 44 | - **Software System Reset** reset mode 45 | 46 | Also, be sure to put the P1 into DFU mode (blinking yellow). In normal operating mode, you likely will not be able to connect by SWD unless you have a SWD-enabled build installed. 47 | 48 | ## About the DCTs 49 | 50 | There are two configuration sectors in the flash memory: 51 | 52 | | Region | Start Address | End Address | Size | 53 | |:---|---|---|---| 54 | | Bootloader | 0x8000000 | 0x8004000 | 16 KB | 55 | | DCT1 | 0x8004000 | 0x8008000 | 16 KB | 56 | | DCT2 | 0x8008000 | 0x800C000 | 16 KB | 57 | | EEPROM1 | 0x800C000 | 0x8010000 | 16 KB | 58 | | EEPROM2 | 0x8010000 | 0x8020000 | 64 KB | 59 | 60 | When the flash is written to, it switches between one sector or the other, so there's no telling which one will be in use. Here's the not in use, blank one, which is all 0xFFs. 61 | 62 | ![blank](blank.png) 63 | 64 | And the not blank one, which isn't all 0xFFs 65 | 66 | ![notblank](notblank.png) 67 | 68 | Within that flash is the configuration for the Wi-Fi module, as well as the Particle configuration. That's this mapping from the data sheet: 69 | 70 | 71 | | Region | Offset | Size | 72 | |:---|---|---| 73 | | system flags | 0 | 32 | 74 | | version | 32 | 2 | 75 | | device private key | 34 | 1216 | 76 | | device public key | 1250 | 384 | 77 | | ip config | 1634 | 120 | 78 | | feature flags | 1754 | 4 | 79 | | country code | 1758 | 4 | 80 | | claim code | 1762 | 63 | 81 | | claimed | 1825 | 1 | 82 | | ssid prefix | 1826 | 26 | 83 | | device code | 1852 | 6 | 84 | | version string | 1858 | 32 | 85 | | dns resolve | 1890 | 128 | 86 | | reserved1 | 2018 | 64 | 87 | | server public key | 2082 | 768 | 88 | | padding | 2850 | 2 | 89 | | flash modules | 2852 | 100 | 90 | | product store | 2952 | 24 | 91 | | antenna selection | 2976 | 1 | 92 | | cloud transport | 2977 | 1 | 93 | | alt device public key | 2978 | 128 | 94 | | alt device private key | 3106 | 192 | 95 | | alt server public key | 3298 | 192 | 96 | | alt server address | 3490 | 128 | 97 | | device id | 3618 | 12 | 98 | | radio flags | 3630 | 1 | 99 | | mode button mirror | 3631 | 32 | 100 | | led mirror | 3663 | 96 | 101 | | led theme | 3759 | 64 | 102 | | reserved2 | 3823 | 435 | 103 | 104 | What's a little less obvious is that this is 0x1d7c (7548) bytes into the DCT. 105 | 106 | So if you want to private key, you take the DCT offset 0x1d7c and add in the offset (34 = 0x22) and you get 0x01d7c + 0x22 = 0x1d9e. 107 | 108 | And that starts the start of either DCT1 (0x08004000) or DCT2 (0x08008000): 109 | 110 | - 0x08004000 + 0x1d7c + 0x22 = 0x08005dc0 111 | - 0x08008000 + 0x1d7c + 0x22 = 0x08009dc0 112 | 113 | That's the offset you want to read from and you want 1216 (0x4c0) bytes. 114 | 115 | ![private key](privatekey.png) 116 | 117 | You can then use the File-Save option to save this as a .bin file. 118 | 119 | If you're using openocd, from the telnet interface: 120 | 121 | ``` 122 | dump_image devprivatekey.bin 0x08009dc0 0x4c0 123 | ``` 124 | 125 | If you're experimenting with a P1 that has a USB interface, you can test this out using dfu-util: 126 | 127 | ``` 128 | dfu-util -d 2b04:d00a -a 1 -s 34:1216 -U devprivatekey.bin 129 | ``` 130 | 131 | This should produce the same bytes as ST-LINK does. 132 | 133 | It should also be the same as: 134 | 135 | ``` 136 | particle keys save device.der 137 | ``` 138 | 139 | The file generated by particle keys save will be shorter as the 0xFF padding at the end is removed. The .bin files are really der encoded RSA private keys. 140 | 141 | On the Mac, Linux, or Windows using cygwin, you may be able to use the od program to display the private key nicely: 142 | 143 | ``` 144 | od -A x -t x1 devprivatekey.bin 145 | ``` 146 | 147 | (That says to show the addresses in hex, and show the data in 1 byte hex quantities.) 148 | 149 | ## Uploading the key 150 | 151 | Once you have .bin file from ST-LINK or openocd, you need to get the PEM formatted public key. This is done using openssl: 152 | 153 | ``` 154 | openssl rsa -in devprivatekey.bin -inform DER -pubout -out device.pub.pem 155 | ``` 156 | 157 | Under Windows, openssl may not be in your path and you may need to specify the full path: 158 | 159 | ``` 160 | c:\OpenSSL-WIN32\bin\openssl rsa -in devprivatekey.bin -inform DER -pubout -out device.pub.pem 161 | ``` 162 | 163 | You can then use the particle keys send program to upload your device public key to the cloud. 164 | 165 | ``` 166 | particle keys send YOUR_DEVICE_ID device.pub.pem 167 | ``` 168 | 169 | -------------------------------------------------------------------------------- /fixing-p1-keys-using-jtag/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-p1-keys-using-jtag/blank.png -------------------------------------------------------------------------------- /fixing-p1-keys-using-jtag/notblank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-p1-keys-using-jtag/notblank.png -------------------------------------------------------------------------------- /fixing-p1-keys-using-jtag/privatekey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-p1-keys-using-jtag/privatekey.png -------------------------------------------------------------------------------- /fixing-p1-keys-using-jtag/stlink.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-p1-keys-using-jtag/stlink.jpg -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/README.md: -------------------------------------------------------------------------------- 1 | # Fixing Windows 10 Serial Drivers 2 | 3 | 4 | This guide has some tips for debugging driver issues with Windows 10. There is a separate guide for [Windows 7](https://github.com/rickkas7/particle_notes/tree/master/debugging-windows-7-drivers). 5 | 6 | ## Getting Started 7 | 8 | One common bit of confusion is that there are two different drivers used, one for normal operating mode with serial enabled and listening mode (blinking dark blue) that maps to a COM port, and a separate set of drivers for use in DFU mode (blinking yellow). It is possible for one set of drivers to work and not the other. 9 | 10 | ## COM Serial Driver 11 | 12 | The COM port serial driver is used in normal operating mode (Serial object) and in listening mode (blinking dark blue). To check the serial drivers, open the **Device Manager**. The easiest way in Windows 10 is to type **Device** in the **Type here to search** box in the lower left corner of the screen next to the Windows button. 13 | 14 | With a Particle device connected by USB and in normal operating mode, listening mode, or safe mode, it should look like this in **Ports (COM & LPT)**. 15 | 16 | ![Device Manager](images/device-manager.png) 17 | 18 | If you view the USB Serial Device properties: 19 | 20 | ![Device Properties](images/device-properties.png) 21 | 22 | And the **Driver** tab in the properties: 23 | 24 | ![Driver Details](images/driver-details.png) 25 | 26 | Note that it should be using the Microsoft Windows serial driver. 27 | 28 | ### The Old Serial Driver 29 | 30 | It's possible to have the old serial driver installed in Windows 10. If this happens, you should manually remove it. 31 | 32 | If the device shows up as Photon, Electron, Argon, Boron, etc. you probably still have the old driver installed. 33 | 34 | ![Old Driver Device Manager](images/old-driver-list.png) 35 | 36 | You can tell for sure from the **Properties** as it will list **Particle** as the **Driver Provider**. 37 | 38 | ![Old Driver Properties](images/old-driver-properties.png) 39 | 40 | Another possibility is that it has a **libwdi** driver, which generally works, except for web-based USB, where it will cause an Access Denied Error. Switching to the Windows driver will still allow the Particle CLI to work, and works properly with WebUSB. 41 | 42 | ![Old Driver libwdi](images/old-libwdi.png) 43 | 44 | ### Removing the Old Serial Driver 45 | 46 | To remove the old driver, exit the Device Manager and disconnect all Particle devices from USB. 47 | 48 | Open an Administrator Command Prompt. In the **Type here to search** box in the lower left corner of the screen next to the Windows button type **Command** (1). Right click on **Command Prompt** (2). Select **Run as administrator** (3). 49 | 50 | ![Admin Command Prompt](images/admin-command-prompt.png) 51 | 52 | In the command prompt, enter the commands: 53 | 54 | ``` 55 | set devmgr_show_nonpresent_devices=1 56 | devmgmt.msc 57 | ``` 58 | 59 | ![Show Non-Present](images/show-nonpresent.png) 60 | 61 | Then from the Device Manager **View** menu (1), select **Show hidden devices** (2). 62 | 63 | ![Show hidden devices](images/show-hidden-devices.png) 64 | 65 | If your device list only shows **USB Serial Device** in **Ports (COM & LPT)** you skip down the the DFU mode instructions below. The correct serial driver is assigned. 66 | 67 | ![Hidden devices](images/hidden-devices.png) 68 | 69 | However if you have Particle devices in the device list, you'll need to remove those devices. 70 | 71 | ![Old hidden devices](images/old-hidden.png) 72 | 73 | Select a Particle device item (Photon, Electron, Argon, Boron, etc.) and hit the Delete key, or right-click and select **Uninstall**. 74 | 75 | Make sure you select the **Delete driver software for this device** checkbox, otherwise the Particle device driver will come back when you plug the device back in. 76 | 77 | The item will disappear. Repeat for all of the Particle device items. 78 | 79 | This should clear up any issues caused by having the old serial driver installed. 80 | 81 | 82 | ## DFU Drivers 83 | 84 | The DFU drivers are only used when your Particle device is blinking yellow. You typically enter DFU mode by holding down RESET and MODE, releasing RESET and continuing to hold down MODE while it blinks magenta (red and blue at the same time) until it blinks yellow, then release. (The button is labeled SETUP, not MODE, on the Photon.) 85 | 86 | In the Device Manager, check and see if there are any devices under **libusbK** or **libusb-win32**. These are the wrong driver and must be changed to use web-based USB (WebUSB) from a browser. 87 | 88 | ![libusbK devices](images/libusbk.png) 89 | 90 | ![libusb-win32 devices](images/libusb.png) 91 | 92 | Select a Particle device item (Photon, Electron, Argon, Boron, etc.) and hit the Delete key, or right-click and select **Uninstall**. 93 | 94 | Make sure you select the **Delete driver software for this device** checkbox, otherwise the Particle device driver will come back when you plug the device back in. 95 | 96 | ![Delete Software](images/boron-delete.png) 97 | 98 | - [Download the Zadig utility](https://zadig.akeo.ie/) and run it. It requires Administrator privileges. 99 | - Connect the device by USB to your computer 100 | - Make sure the device is in DFU mode (blinking yellow). If not, hold down the MODE button and tap RESET. Continue to hold down MODE (SETUP on the Photon) while the status LED blinks magenta (red and blue at the same time) until it blinks yellow, then release MODE. 101 | - In the **View** menu, select **List All Devices** 102 | - Select **Boron DFU Mode** (or whatever device you have) 103 | - Select **WinUSB**. 104 | - Click **Install WCID Driver** (this may take a few minutes) 105 | 106 | ![Zadig](images/zadig.png) 107 | -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/admin-command-prompt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/admin-command-prompt.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/boron-delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/boron-delete.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/device-manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/device-manager.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/device-properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/device-properties.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/driver-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/driver-details.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/hidden-devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/hidden-devices.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/libusb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/libusb.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/libusbk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/libusbk.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/old-driver-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/old-driver-list.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/old-driver-properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/old-driver-properties.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/old-hidden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/old-hidden.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/old-libwdi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/old-libwdi.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/show-hidden-devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/show-hidden-devices.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/show-nonpresent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/show-nonpresent.png -------------------------------------------------------------------------------- /fixing-windows-10-serial-drivers/images/zadig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/fixing-windows-10-serial-drivers/images/zadig.png -------------------------------------------------------------------------------- /forcing-electron-ota-system-firmware-update/README.md: -------------------------------------------------------------------------------- 1 | # Forcing an Electron OTA System Firmware Update 2 | 3 | Once in a while you may find that an Electron will get stuck in safe mode after initiating a product firmware update that requires a system firmware update. Most of the time you can get the device out of this state by manually flashing the system firmware parts OTA. 4 | 5 | ## Get the system firmware binaries 6 | 7 | You must download the 3 Electron system firmware binary parts (2 parts for 0.5.3) first. You can use any compatible version, but here are some common ones. 8 | 9 | Note that even if your product firmware only requires 0.6.2, for example, you can still install 0.6.4 on your device. 10 | 11 | ### 0.6.4 12 | 13 | [0.6.4 Release](https://github.com/particle-iot/firmware/releases/tag/v0.6.4) 14 | 15 | - [system-part1-0.6.4-electron.bin](https://github.com/particle-iot/firmware/releases/download/v0.6.4/system-part1-0.6.4-electron.bin) 16 | - [system-part2-0.6.4-electron.bin](https://github.com/particle-iot/firmware/releases/download/v0.6.4/system-part2-0.6.4-electron.bin) 17 | - [system-part3-0.6.4-electron.bin](https://github.com/particle-iot/firmware/releases/download/v0.6.4/system-part3-0.6.4-electron.bin) 18 | 19 | 20 | ### 0.5.5 21 | 22 | [0.5.5 Release](https://github.com/particle-iot/firmware/releases/tag/v0.5.5) 23 | 24 | - [system-part1-0.5.5-electron.bin](https://github.com/particle-iot/firmware/releases/download/v0.5.5/system-part1-0.5.5-electron.bin) 25 | - [system-part2-0.5.5-electron.bin](https://github.com/particle-iot/firmware/releases/download/v0.5.5/system-part2-0.5.5-electron.bin) 26 | 27 | 28 | ## Important warning for versions prior to 0.5.3 29 | 30 | Important note: If the device previously had a version prior to 0.5.3, such as the original factory default of 0.4.6, you must do a two-stage upgrade. First to 0.5.3 (or 0.5.4 or 0.5.5), then to whatever version you want, like 0.6.4. If you fail to do this, you will likely get the device into a state where you'll have to do a USB system firmware update to get out of the state. 31 | 32 | ## Set up the upload script 33 | 34 | There isn't a built-in command in the Particle CLI for doing this, so you'll need to use curl and a script. This will work on Mac and Linux, and should work under Windows using Cygwin. 35 | 36 | Here's the script: 37 | 38 | ``` 39 | #!/bin/bash 40 | 41 | # usage: ./flash.sh 42 | if [ -z "$2"]; then 43 | echo "USAGE: ./flash.sh " 44 | exit 1; 45 | fi 46 | 47 | # Replace 1234 with your product number! 48 | 49 | curl -X PUT "https://api.particle.io/v1/products/1234/devices/"${1}"?access_token=PASTE_ACCESS_TOKEN_HERE" \ 50 | -F file=@${2} \ 51 | -F file_type=binary 52 | ``` 53 | 54 | Make sure you edit these two things: 55 | 56 | - Replace 1234 in the URL with your product number 57 | - Replace `PASTE_ACCESS_TOKEN_HERE` with the access token you get in the next step. 58 | 59 | Of course you could just type the curl command directly, but it's a little unwieldy and hard to remember. 60 | 61 | ## Get an access token 62 | 63 | To get a product access token, click on: 64 | 65 | - Your product 66 | - Devices (that's usually already selected) 67 | - View a single device 68 | - Click **See in Terminal** 69 | 70 | ![see in terminal](see_in_terminal.png) 71 | 72 | That screen will show you an access token that you can paste into the previous step. Note that this access token will be revoked when you close the console window for security reasons. 73 | 74 | 75 | ## Flash the code 76 | 77 | You need to flash each of the 3 parts in sequence, but you need to wait until the operation is complete before moving onto the next part. The easiest way to do this is to monitor the Event Log, the best choice is usually the device event log in the console, since it only shows events for the device you are interested in. 78 | 79 | Using the script above: 80 | 81 | ``` 82 | bash flash.sh 28c8b06ce19895f2178193b0 system-part1-0.6.4-electron.bin 83 | ``` 84 | 85 | Wait until the Event logs shows the device come online again in safe mode, then: 86 | 87 | ``` 88 | bash flash.sh 28c8b06ce19895f2178193b0 system-part2-0.6.4-electron.bin 89 | ``` 90 | 91 | And if using 0.6.0 or later, part 3: 92 | 93 | ``` 94 | bash flash.sh 28c8b06ce19895f2178193b0 system-part3-0.6.4-electron.bin 95 | ``` 96 | 97 | (Replace 28c8b06ce19895f2178193b0 with your device ID, of course.) 98 | 99 | 100 | ## Your own developer Electron 101 | 102 | If you're already logged into the CLI as the same account that owns the device, you can more easily just do this using particle flash: 103 | 104 | Make sure you flash the parts in the order 1, 2, 3 and wait for the device to come back online in safe mode before flashing the next part. 105 | 106 | ``` 107 | particle flash 28c8b06ce19895f2178193b0 system-part1-0.6.4-electron.bin 108 | particle flash 28c8b06ce19895f2178193b0 system-part2-0.6.4-electron.bin 109 | particle flash 28c8b06ce19895f2178193b0 system-part3-0.6.4-electron.bin 110 | ``` 111 | -------------------------------------------------------------------------------- /forcing-electron-ota-system-firmware-update/see_in_terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/forcing-electron-ota-system-firmware-update/see_in_terminal.png -------------------------------------------------------------------------------- /installing-curl/README.md: -------------------------------------------------------------------------------- 1 | # Installing curl (for Windows) 2 | 3 | The curl command, used in the [Particle cloud examples](https://docs.particle.io/reference/api/) is generally built-in on the Mac and Linux, but not Windows. These instructions explain how to install it. 4 | 5 | 6 | ## Installation 7 | 8 | ### Download 9 | 10 | Download the files from [https://curl.haxx.se/download.html](https://curl.haxx.se/download.html). You generally want one of the two highlighted files, depending on whether you have 32-bit or 64-bit Windows: 11 | 12 | - Win32 Generic - Win32 zip 7.51.0 binary SSL SSH 13 | - Win64 Generic - Win64 x86_64 zip 7.51.0 binary SSL SSH 14 | 15 | Click on the version number (7.51.0, for example) to download the file. 16 | 17 | If you are unsure, this Microsoft knowledge base article on [how to tell whether you have a 32-bit or 64-bit Windows installation](https://support.microsoft.com/en-us/kb/827218) may be helpful. 18 | 19 | ![Download Options](images/01download.png) 20 | 21 | You should also go to the page [http://curl.haxx.se/docs/caextract.html](http://curl.haxx.se/docs/caextract.html). Right click on the link to cacert.pem and select **Save Target** to save the file to your Downloads folder. 22 | 23 | ![Save Target](images/02savetarget.png) 24 | 25 | You first need to create a place to save your curl installation. I like to put the files in C:\Program Files\curl. In the Windows File Explorer: 26 | 27 | 1. Select This PC 28 | 2. Select your C: drive, called **Windows 10 (C:)** in this example, but your may be different. 29 | 3. Double click Program Files 30 | 31 | ![Create folder in program files](images/10programfiles.png) 32 | 33 | Right click on the right side of the window, select **New** then **Folder**. 34 | 35 | ![Create folder in program files](images/11newfolder.png) 36 | 37 | Name the new folder **curl**. Then moved the files you downloaded into this directory. 38 | 39 | ![Create curl directory in program files](images/03curldir.png) 40 | 41 | Open the .zip file that you downloaded earlier. Inside the **src** folder should be the file **curl.exe**. Copy this into the new directory that you just created. 42 | 43 | ![Copy curl.exe](images/04copy.png) 44 | 45 | Also copy the **cacert.pem.htm** file into the curl directory. 46 | 47 | ![Copy cacert.pem.htm](images/05copy.png) 48 | 49 | Rename the **cacert.pem.htm** file to **curl-ca-bundle.crt**. You should get a warning about changing the filename extension. Click **Yes**. 50 | 51 | ![Rename cacert.pem.htm](images/06rename.png) 52 | 53 | Depending on your system settings, the filename extension may be hidden. This will cause some problems. You can tell because the the curl program is just **curl** not **curl.exe** and also **cacert.pem** is of type **HTML Document**. 54 | 55 | ![No filename extensions](images/07noextension.png) 56 | 57 | One way to fix this is to just turn on filename extension viewing. Open the **Control Panel** and select **Appearance and Personalization**. 58 | 59 | ![Apperance](images/08appearance.png) 60 | 61 | Then **Folder Options**. 62 | 63 | ![Folder Options](images/09folderoptions.png) 64 | 65 | Click the **View** tab (1) and then deselect the checkbox for **Hide extensions for known file types** (2). 66 | 67 | ![Hide Extension](images/10hideext.png) 68 | 69 | Then you can finally rename the file **curl-ca-bundle.crt** and have it show up as type **Security Certificate**. 70 | 71 | ![Rename](images/12rename.png) 72 | 73 | 74 | ### Editing the path - Windows 10 75 | 76 | Click on the Windows Start menu, then the Settings (gear icon). 77 | 78 | ![Start Settings](images/13startsettings.png) 79 | 80 | In the Windows 10 Settings window, type **environment** into the box at the top and select **Edit the system environment variables.** 81 | 82 | ![Settings](images/14settings.png) 83 | 84 | Click the **Environment Variables** button at the bottom of the page. 85 | 86 | ![Enviroment Variables](images/15environmentvariables.png) 87 | 88 | In the **Environment Variables** window, select **Path** in the bottom list (System variables) and click Edit. 89 | 90 | ![Edit](images/16edit.png) 91 | 92 | In the **Edit environment variable** window, click **New** then enter a new row in the table, **C:\Program Files\curl**. 93 | 94 | ![Edit New](images/17editnew.png) 95 | 96 | After editing the system path environment variable you'll need to restart the computer. 97 | 98 | ### Editing the path - Windows 7 and 8 99 | 100 | You need to open the Control Panel. 101 | 102 | ![Open Control Panel](images/05controlpanel.png) 103 | 104 | And then click on **System and Security**. 105 | 106 | ![System and Security](images/06systemandsecurity.png) 107 | 108 | Then click **System**. 109 | 110 | ![System and Secury](images/18system.png) 111 | 112 | Then click on the **Advanced System Settings** link on the left side of the window. 113 | 114 | ![Advanced Settings](images/08advanced.png) 115 | 116 | Then click on **Environment Variables...** 117 | 118 | ![Environment](images/09environment.png) 119 | 120 | Click on **Path** in the bottom list (System variables) and click Edit. 121 | 122 | Finally, position the cursor at the end of the box and add to the end: 123 | 124 | ``` 125 | ;C:\Program Files\curl 126 | ``` 127 | There must be a semicolon separating the new item from the previous last item, and then the path to the directory we just created. 128 | 129 | ![Edit variable](images/19editvar.png) 130 | 131 | After editing the system path environment variable you'll need to restart the computer or log out and log back in. 132 | 133 | ## Testing 134 | 135 | Most calls require an access token. You can create one using the [Particle CLI](https://docs.particle.io/reference/developer-tools/cli/#particle-token-create) command `particle token create`. 136 | 137 | Make sure you keep your token secret, because it allows access and control over all of your devices. 138 | 139 | You should now be able to open a Command Prompt window and type in a command like: 140 | 141 | ``` 142 | curl https://api.particle.io/v1/devices?access_token=PASTE_YOUR_ACCESS_TOKEN_HERE 143 | ``` 144 | 145 | Also note: Many of the examples show a command that continues across lines with a backslash (\\) at the end of the line. This is the correct character for Mac and Linux, but using the Windows Command Prompt you should use the carat (^) instead. 146 | 147 | -------------------------------------------------------------------------------- /installing-curl/images/01download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/01download.png -------------------------------------------------------------------------------- /installing-curl/images/02savetarget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/02savetarget.png -------------------------------------------------------------------------------- /installing-curl/images/03curldir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/03curldir.png -------------------------------------------------------------------------------- /installing-curl/images/04copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/04copy.png -------------------------------------------------------------------------------- /installing-curl/images/05controlpanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/05controlpanel.png -------------------------------------------------------------------------------- /installing-curl/images/05copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/05copy.png -------------------------------------------------------------------------------- /installing-curl/images/06rename.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/06rename.png -------------------------------------------------------------------------------- /installing-curl/images/06systemandsecurity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/06systemandsecurity.png -------------------------------------------------------------------------------- /installing-curl/images/07noextension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/07noextension.png -------------------------------------------------------------------------------- /installing-curl/images/08advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/08advanced.png -------------------------------------------------------------------------------- /installing-curl/images/08appearance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/08appearance.png -------------------------------------------------------------------------------- /installing-curl/images/09environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/09environment.png -------------------------------------------------------------------------------- /installing-curl/images/09folderoptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/09folderoptions.png -------------------------------------------------------------------------------- /installing-curl/images/10hideext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/10hideext.png -------------------------------------------------------------------------------- /installing-curl/images/10programfiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/10programfiles.png -------------------------------------------------------------------------------- /installing-curl/images/11newfolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/11newfolder.png -------------------------------------------------------------------------------- /installing-curl/images/12rename.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/12rename.png -------------------------------------------------------------------------------- /installing-curl/images/13startsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/13startsettings.png -------------------------------------------------------------------------------- /installing-curl/images/14settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/14settings.png -------------------------------------------------------------------------------- /installing-curl/images/15environmentvariables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/15environmentvariables.png -------------------------------------------------------------------------------- /installing-curl/images/16edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/16edit.png -------------------------------------------------------------------------------- /installing-curl/images/17editnew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/17editnew.png -------------------------------------------------------------------------------- /installing-curl/images/18system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/18system.png -------------------------------------------------------------------------------- /installing-curl/images/19editvar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/19editvar.png -------------------------------------------------------------------------------- /installing-curl/images/20accesstoken.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-curl/images/20accesstoken.png -------------------------------------------------------------------------------- /installing-dfu-util/files/50-particle.rules: -------------------------------------------------------------------------------- 1 | # UDEV Rules for Particle boards 2 | # 3 | # This will allow reflashing with DFU-util without using sudo 4 | # 5 | # The latest version of this file may be found at: 6 | # https://gist.github.com/monkbroc/b283bb4da8c10228a61e 7 | # 8 | # This file must be placed at: 9 | # 10 | # /etc/udev/rules.d/50-particle.rules (preferred location) 11 | # 12 | # To install, type this command in a terminal: 13 | # sudo cp 50-particle.rules /etc/udev/rules.d/50-particle.rules 14 | # 15 | # After this file is installed, physically unplug and reconnect the 16 | # Particle device. 17 | # 18 | # Core 19 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="607[df]", GROUP="plugdev", MODE="0666" 20 | # Photon/P1/Electron 21 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2b04", ATTRS{idProduct}=="[cd]00?", GROUP="plugdev", MODE="0666" 22 | # 23 | # If you share your linux system with other users, or just don't like the 24 | # idea of write permission for everybody, you can replace MODE:="0666" with 25 | # OWNER:="yourusername" to create the device owned by you, or with 26 | # GROUP:="somegroupname" and mange access using standard unix groups. 27 | # 28 | # 29 | # If using USB Serial you get a new device each time (Ubuntu >9.10) 30 | # eg: /dev/ttyACM0, ttyACM1, ttyACM2, ttyACM3, ttyACM4, etc 31 | # apt-get remove --purge modemmanager (reboot may be necessary) 32 | # 33 | # CREDITS: 34 | # 35 | # Edited by Julien Vanier 36 | # 37 | # This file is derived from the Teensy UDEV rules 38 | # http://www.pjrc.com/teensy/49-teensy.rules 39 | # -------------------------------------------------------------------------------- /installing-dfu-util/images/01zadig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/01zadig.png -------------------------------------------------------------------------------- /installing-dfu-util/images/02download32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/02download32.png -------------------------------------------------------------------------------- /installing-dfu-util/images/03programfiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/03programfiles.png -------------------------------------------------------------------------------- /installing-dfu-util/images/04dfufiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/04dfufiles.png -------------------------------------------------------------------------------- /installing-dfu-util/images/05controlpanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/05controlpanel.png -------------------------------------------------------------------------------- /installing-dfu-util/images/06systemandsecurity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/06systemandsecurity.png -------------------------------------------------------------------------------- /installing-dfu-util/images/08advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/08advanced.png -------------------------------------------------------------------------------- /installing-dfu-util/images/09environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/09environment.png -------------------------------------------------------------------------------- /installing-dfu-util/images/10programfiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/10programfiles.png -------------------------------------------------------------------------------- /installing-dfu-util/images/11newfolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/11newfolder.png -------------------------------------------------------------------------------- /installing-dfu-util/images/12copyfiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/12copyfiles.png -------------------------------------------------------------------------------- /installing-dfu-util/images/13startsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/13startsettings.png -------------------------------------------------------------------------------- /installing-dfu-util/images/14settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/14settings.png -------------------------------------------------------------------------------- /installing-dfu-util/images/15environmentvariables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/15environmentvariables.png -------------------------------------------------------------------------------- /installing-dfu-util/images/16edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/16edit.png -------------------------------------------------------------------------------- /installing-dfu-util/images/17editnew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/17editnew.png -------------------------------------------------------------------------------- /installing-dfu-util/images/18system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/18system.png -------------------------------------------------------------------------------- /installing-dfu-util/images/19editvar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/19editvar.png -------------------------------------------------------------------------------- /installing-dfu-util/images/20command.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/20command.png -------------------------------------------------------------------------------- /installing-dfu-util/images/21command.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/21command.png -------------------------------------------------------------------------------- /installing-dfu-util/images/22dfu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/22dfu.png -------------------------------------------------------------------------------- /installing-dfu-util/images/23com.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/23com.png -------------------------------------------------------------------------------- /installing-dfu-util/images/24zadig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/installing-dfu-util/images/24zadig.png -------------------------------------------------------------------------------- /installing-openssl/README.md: -------------------------------------------------------------------------------- 1 | # Installing OpenSSL for Windows 2 | 3 | OpenSSL is a set of encryption tools. It's used when you need to update or repair the encryption keys on your Particle Photon, Electron, etc.. It's generally already installed for Mac and Linux, so this note is specifically for Windows. 4 | 5 | The easiest way to install OpenSSL is to use the [Particle CLI Installer for Windows](https://binaries.particle.io/cli/installer/windows/ParticleCLISetup.exe), which installs it for you. 6 | 7 | If you'd like to install it manually, or debug an existing installation, you can follow the instruction in the sections below that. 8 | 9 | ## Using the Windows Particle CLI installer 10 | 11 | The easiest way to install OpenSSL is to use the [Particle CLI Installer for Windows](https://binaries.particle.io/cli/installer/windows/ParticleCLISetup.exe), which installs it for you. However it may not update the PATH, so you may need to do a few additional steps to use it. 12 | 13 | The installation defaults to **C:\OpenSSL-Win32**. 14 | 15 | If you want to use the CLI particle keys doctor command, for example, you will want to cd to that directory first: 16 | 17 | ``` 18 | cd c:\OpenSSL-Win32\bin 19 | particle keys doctor 12345678901234567890abcd 20 | ``` 21 | 22 | Alternatively, you can add it your PATH environment variable. An explanation of how to do this can be found here: 23 | 24 | [https://github.com/rickkas7/particle_notes/tree/master/modifying-path](https://github.com/rickkas7/particle_notes/tree/master/modifying-path) 25 | 26 | Just make sure you substitute **C:\OpenSSL-Win32\bin** for **C:\Program Files\dfu-util** in the final step. 27 | 28 | 29 | ## Download binaries 30 | 31 | The binaries are available for both Windows 32-bit and 64-bit. If you are unsure of whether you have 32-bit or 64-bit windows, this Microsoft knowledge base article on [how to tell whether you have a 32-bit or 64-bit Windows installation](https://support.microsoft.com/en-us/kb/827218) may be helpful. 32 | 33 | The downloads are here: 34 | 35 | [https://indy.fulgan.com/SSL/](https://indy.fulgan.com/SSL/) 36 | 37 | You typically want the newest version; at the time of writing it is openssl-1.0.2k, so you'd download one of these two files: 38 | 39 | - [openssl-1.0.2k-i386-win32.zip](https://indy.fulgan.com/SSL/openssl-1.0.2k-i386-win32.zip) 40 | - [openssl-1.0.2k-x64_86-win64.zip](https://indy.fulgan.com/SSL/openssl-1.0.2k-x64_86-win64.zip) 41 | 42 | ## Install binaries 43 | 44 | - Go into your **Downloads** folder 45 | - Select the zip file that you download 46 | - Right click and select **Extract All** 47 | - This should create an **openssl-1-2** folder. 48 | - Drag this folder to where you want to store your OpenSSL installation. I like to put it in **C:\Program Files**. 49 | 50 | ## Update your PATH 51 | 52 | The final step is to update your PATH environment variable to add the directory you just created, for example: **C:\Program Files\openssl-1-2**. 53 | 54 | An explanation of how to do this can be found here: 55 | 56 | [https://github.com/rickkas7/particle_notes/tree/master/modifying-path](https://github.com/rickkas7/particle_notes/tree/master/modifying-path) 57 | 58 | Just make sure you substitute **C:\Program Files\openssl-1-2** for **C:\Program Files\dfu-util** in the final step. 59 | 60 | ## Verifying 61 | 62 | You may need to log out of your Windows session (or restart your computer), but then you should be able to open a command prompt and do: 63 | 64 | ``` 65 | openssl --version 66 | ``` 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /mac-serial-tips/README.md: -------------------------------------------------------------------------------- 1 | # Mac Serial Tips 2 | 3 | In general, the Particle Photon/Electron/Core just work with the Mac when you plug it in. However, if things don't work, here are some tips that may help debug the problem. 4 | 5 | ## There are two modes 6 | 7 | The Photon/Electron/Core have two different operating modes: 8 | 9 | - In listening mode (blinking blue) and normal operating mode with serial enabled, the device appears as a USB serial port 10 | - In DFU mode (blinking yellow), the device is only visible to dfu-util 11 | 12 | This is important, because it's possible for the device to work in one mode or the other, and the fixes are sometimes different. 13 | 14 | When in normal operating mode (breathing cyan, green, white, etc.), the Photon/Electron/Core will also appear as a serial device, as long as you call: 15 | 16 | ``` 17 | Serial.begin(9600); 18 | ``` 19 | 20 | This is typically during setup(). The baud rate (9600) is ignored. In newer system firmware versions it can be omitted. You might see other values like 19200 or 115200, but the USB serial port runs at a fast speed regardless of what you set. 21 | 22 | ## Particle CLI Installation 23 | 24 | In order to install the Particle CLI on the Mac, you typically need to do two things: 25 | 26 | - Install [node.js](https://nodejs.org). I recommend the LTS version (currently v6.10.0). 27 | - Install the Particle CLI: 28 | 29 | ``` 30 | sudo npm install -g particle-cli 31 | ``` 32 | 33 | If you have upgraded node, you may get an error installing serial port, having something to do with pre-gyp. This can usually be solved by manually removing the old version first: 34 | 35 | ``` 36 | sudo npm uninstall -g particle-cli 37 | ``` 38 | 39 | If you have recently upgraded your operating system, you may want to reinstall [Homebrew](https://brew.sh). It's not so much that Homebrew needs reinstallation, but upgrading Mac OS X will uninstall the command line build tools, which may affect the ability to build the serial port driver for node. Reinstalling Homebrew is usually easier than installing Xcode and the command line tools. 40 | 41 | Sometimes this command helps, as well: 42 | 43 | ``` 44 | sudo npm install -g node-pre-gyp npm serialport particle-cli 45 | ``` 46 | 47 | 48 | ## USB-3 Ports 49 | 50 | In the past, a few people have had trouble using Mac laptops with USB-3 USB ports. This hasn't happened recently, but putting a USB hub in between the laptop and the Photon has solved the problem. 51 | 52 | ## Cables 53 | 54 | It's not a bad idea to try a different USB cable as well. In addition to defective cables, beware of some charging cables, which only provide power and do not allow access to the port for data. 55 | 56 | 57 | ## In Listening Mode (blinking blue) 58 | 59 | To put a Photon in [listening mode](https://docs.particle.io/guide/getting-started/modes/photon/#listening-mode), hold down the SETUP button until the status LED blinks dark blue. 60 | 61 | To put an Electron in [listening mode](https://docs.particle.io/guide/getting-started/modes/electron/#listening-mode), hold down the MODE button until the status button blinks dark blue. 62 | 63 | When the Photon or Electron is in listening mode, a serial port device should be created. The ls command can be used to show the available ports: 64 | 65 | ``` 66 | Ricks-Mac:~ rickk$ ls /dev/cu.usb* /dev/cu.usbmodem1D11 67 | ``` 68 | 69 | This means the port has been created, and is /dev/cu.usbmodem1D11 in this case. The part after usbmodem will vary, for example it might be cu.usbmodemFD3141 or cu.usbmodemFD1161 or pretty much anything. 70 | 71 | If you have the [Particle CLI](https://docs.particle.io/guide/tools-and-features/cli/) installed, you should be able to get information about your device like this: 72 | 73 | ``` 74 | Ricks-Mac:~ rickk$ particle identify Your device id is 3b0021001747353236343033 Your system firmware version is 0.6.1 ``` 75 | 76 | If not, you can use the screen command: 77 | 78 | ``` 79 | screen /dev/cu.usbmodem1D11 80 | ``` 81 | 82 | The terminal window will clear, and then type **i** (lowercase i, as in identify). It should display something like this (your device ID will be different, of course). 83 | 84 | ``` 85 | Your device id is 3b0021001747353236343033 86 | ``` 87 | 88 | To get out of screen, press Ctrl-A, then d. If that doesn't work, just close the Terminal window. 89 | 90 | If that doesn't work, you should check the device entry using the ioreg command. It should return something like this for the Photon: 91 | 92 | ``` 93 | Ricks-Mac:~ rickk$ ioreg -p IOUSB -n Photon +-o Root +-o Root Hub Simulation Simulation@fd000000 +-o Root Hub Simulation Simulation@fd000000 = 2) { 15 | options.data = argv._[1]; 16 | } 17 | 18 | 19 | /* 20 | - Open, unsecured AP 21 | - SSID is "photon-xxxxx" where xxxxx is part of the unique device ID 22 | - IP 192.168.0.1 23 | 24 | ## Endpoints 25 | - TCP/5609 : simple protocol 26 | - request is: 27 | - command name [a-zA-z0-9-_]+ LF 28 | - number of bytes in body in ascii, e.g. '5' '7' for 57 bytes. LF 29 | - LF (empty line delimiter), followed by the JSON representation of the request data (if the command request requires one) 30 | - response: 31 | - line delimited header data (if any) followed by an empty line (\n\n) 32 | - command result as JSON 33 | - one request/response pair per socket connection 34 | */ 35 | 36 | async function run() { 37 | options.request = ''; 38 | 39 | options.request += options.command + '\n'; 40 | 41 | if (options.data) { 42 | options.request += options.data.length.toString() + '\n'; 43 | options.request += '\n'; 44 | options.request += options.data; 45 | } 46 | else { 47 | // No data 48 | options.request += '0\n\n'; 49 | } 50 | 51 | 52 | console.log('options', options); 53 | 54 | const client = new net.Socket(); 55 | 56 | client.connect(5609, '192.168.0.1', function() { 57 | console.log('client connected'); 58 | client.write(options.request); 59 | // client.end(); 60 | }); 61 | 62 | client.on('data', function(data) { 63 | console.log('data', data.toString()); 64 | }); 65 | 66 | client.on('close', function() { 67 | console.log('closed'); 68 | }); 69 | } 70 | 71 | run(); 72 | -------------------------------------------------------------------------------- /manual-photon-claiming/tcp-setup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rickkas7/tcp-setup", 3 | "version": "0.0.1", 4 | "description": "test program for Particle Photon wifi setup over TCP", 5 | "license": "MIT", 6 | "private": true, 7 | "dependencies": { 8 | "node-rsa": "^1.1.1", 9 | "yargs": "^16.1" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /manual-photon-claiming/wifipass/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"@rickkas7/wifipass", 3 | "version":"0.0.1", 4 | "description":"test program for Particle Photon wifi password encryption", 5 | "license":"MIT", 6 | "private":true, 7 | "dependencies" : { 8 | "yargs" : "^7.0.0", 9 | "node-rsa": "^0.4.2" 10 | } 11 | } -------------------------------------------------------------------------------- /manual-photon-claiming/wifipass/wifipass.js: -------------------------------------------------------------------------------- 1 | 2 | var argv = require('yargs').demandCommand(2).argv; 3 | 4 | var NodeRSA = require('node-rsa'); 5 | 6 | var key = argv._[0]; 7 | var password = argv._[1]; 8 | 9 | // console.log("key=" + key + " password=" + password); 10 | 11 | var keyBuf = Buffer.from(key.substring(44), 'hex'); 12 | 13 | var rsa = new NodeRSA(keyBuf, 'pkcs1-public-der', { 14 | encryptionScheme: 'pkcs1' 15 | }); 16 | 17 | console.log("encrypted password: " + rsa.encrypt(password, 'hex')); 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /measuring-electron-power/README.md: -------------------------------------------------------------------------------- 1 | # Measuring Electron power consumption 2 | 3 | *Tips for measuring Electron power consumption using an inexpensive digital multimeter (DMM)* 4 | 5 | One of the difficulties with measuring power consumption of an Electron is the wide variation of power usage. It may use 1800 mA when connecting to a cellular tower (2G model), but as little as 90 µA in deep sleep mode. This can cause measurement difficulties with inexpensive DMMs. 6 | 7 | ![Battery](battery.jpg) 8 | 9 | I prefer to test using a battery, as that's most likely the situation you'll be interested in low power consumption, and when using, say, VIN, some of the current could be directed to charging the battery. 10 | 11 | I spliced a switch into the battery circuit as well. This makes it easier to disconnect the battery without having to unplug the JST power connector. 12 | 13 | Also, there's a male pin to female plug socket spliced in there, as well, and that's what used for current measurement. 14 | 15 | ![Meter](meter.jpg) 16 | 17 | As a schematic, it may make more sense: 18 | 19 | ![Circuit](circuit.png) 20 | 21 | The slide switch on the left is the power switch, which disconnects the battery. 22 | 23 | The toggle switch on the right is the bypass switch, that shunts the meter connection. This is important. 24 | 25 | You also want to make sure you have really good connections. You won't be able to keep a good enough connection just by pressing the meter probes against wires. 26 | 27 | ## The DMM scale dilemma 28 | 29 | Like most DMMs, this one has multiple ranges, in this case, three: A, mA, and µA. 30 | 31 | The problem is that when you're in the µA scale, the meter does not provide sufficient current for the Electron to properly operate. Essentially, the Electron is starved for power if it tries to power up, and this causes the modem to not operate properly. Among other things, the modem cannot go to sleep when it does not have sufficient power. If your Electron is consuming 2 mA to 40 mA when it should be in deep sleep mode, this is one of the possible causes. 32 | 33 | Some meters can power the Electron in mA scale, and some may require the A (amps) scale. 34 | 35 | The other problem is that most meters disconnect the circuit when you switch between modes, this interruption in power confuses the Electron, and may cause it to reboot, or at least not function reliably. 36 | 37 | The solution to all of this is the use of the bypass switch, above. 38 | 39 | ## Testing tips 40 | 41 | To eliminate any software issues and make sure you have your meter set up properly, it's a good idea to just [flash the Tinker app](https://github.com/rickkas7/particle_notes/tree/master/restoring-tinker) to your Electron. 42 | 43 | Close the bypass switch so the meter is not supplying the current and power on the Electron. 44 | 45 | If you double-tap the MODE button with the Electron, it should go into deep sleep mode after several seconds. 46 | 47 | Once the status LED is off, put the meter in uA scale and open the bypass switch. The Electron should be consuming about 90 µA in this mode, as shown in the picture above. 48 | 49 | ## More on sleep modes 50 | 51 | There are a few caveats to entering sleep mode from your code. [The tips in this post](https://community.particle.io/t/electron-sleep-mode-deep-tips-and-examples/27823) may be helpful. 52 | -------------------------------------------------------------------------------- /measuring-electron-power/battery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/measuring-electron-power/battery.jpg -------------------------------------------------------------------------------- /measuring-electron-power/circuit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/measuring-electron-power/circuit.png -------------------------------------------------------------------------------- /measuring-electron-power/meter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/measuring-electron-power/meter.jpg -------------------------------------------------------------------------------- /mesh-io-notes/README.md: -------------------------------------------------------------------------------- 1 | # Particle Mesh IO notes 2 | 3 | We're still a few months from release of the Argon, Boron, and Xenon, but there's some interesting publicly available information we can peruse until the official documentation comes out. 4 | 5 | The new devices all conform to the [Adafruit Feather Specification](https://learn.adafruit.com/adafruit-feather/feather-specification). That provides the specs for the number of pins (12 on one side, 16 on the other), spacing, and the general functions. 6 | 7 | The next thing is the official final Xenon pinout has been released. 8 | 9 | ![Xenon pinout](xenon.png) 10 | 11 | Finally, you'll want to download the [nRF52840 Product Specification](http://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.0.pdf). 12 | 13 | **IMPORTANT:** *The information in this document is subject to change and may be in fact be wrong. It is based only from reviewing the publicly available documentation. Not all features available in hardware may be exposed by the system firmware.* 14 | 15 | ## GPIO 16 | 17 | On the nRF52840, most pins can be used as GPIO. This includes the D pins, A pins, and the specialty ports like SPI, I2C, and serial, if you aren't using them. This is basically the same as the STM32. 18 | 19 | ## Analog Input (ADC) 20 | 21 | There are 6 exposed ADC inputs A0-A5. 22 | 23 | While the nRF52840 supports 8 ADC channels, the other two are P0.02 and P0.05, which are not exposed, so there are only 6. You can use an I2C or SPI ADC, of course. 24 | 25 | ## Serial 26 | 27 | There is a serial port on the RX and TX pins, and it supports optional hardware flow control (CTS/RTS on D3 and D2). 28 | 29 | | Serial | Alt | nRF52840 | 30 | | ------ | --- | -------- | 31 | | TX | D9 | P0.06 | 32 | | RX | D10 | P0.08 | 33 | | CTS | D3 | P1.02 | 34 | | RTS | D2 | P1.01 | 35 | 36 | 37 | The nRF52840 has two hardware UARTs, and the optional second UART should be available on these pins. This could change. 38 | 39 | | Serial | Alt | nRF52840 | 40 | | ------ | --- | -------- | 41 | | TX1 | D4 | P1.08 | 42 | | RX1 | D5 | P1.10 | 43 | | CTS1 | D6 | P1.11 | 44 | | RTS1 | D8 | P1.03 | 45 | 46 | ## I2C 47 | 48 | There is a dedicated set of pins for I2C on D0 and D1, just like the Photon and Electron. 49 | 50 | The nRF52840 is more flexible than the STM32, however. There are two shared peripherals for I2C: 51 | 52 | - ID 3 = I2C Master 0, I2C Slave 0 (it not used for SPI) 53 | - ID 4 = I2C Master 1, I2C Slave 1 (if not used for SPI) 54 | 55 | What this means is that you can have two I2C masters, one of each, or two I2C slaves, and they can be mapped to any GPIO. 56 | 57 | It gets more complicated than that because some of the shared peripherals are shared with SPI. However, there are 4 SPI peripherals, so hopefully it will be possible to move things around if necessary. 58 | 59 | And remember: not all of these hardware feature may be exposed by system firmware. 60 | 61 | ## SPI 62 | 63 | There's a dedicated set of pins for SPI. 64 | 65 | The nRF52840 is more flexible than the STM32, however. There four SPI peripherals that can be assigned to any pins. However, two of the shared peripherals are shared with I2C, so you can only have four SPI ports if you don't use I2C. 66 | 67 | - ID 3 = SPI Master 0 or SPI Slave 0 (if not used for I2C) 68 | - ID 4 = SPI Master 1 or SPI Slave 1 (if not used for I2C) 69 | - ID 35 = SPI Master 2 or SPI Slave 2 70 | - ID 46 = SPI Master 3 71 | 72 | And remember: not all of these hardware feature may be exposed by system firmware. 73 | 74 | 75 | -------------------------------------------------------------------------------- /mesh-io-notes/xenon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/mesh-io-notes/xenon.png -------------------------------------------------------------------------------- /modifying-path/README.md: -------------------------------------------------------------------------------- 1 | # Modifying your path 2 | 3 | The path is a configuration setting that determines what directories contain programs you can execute from the command line. 4 | 5 | ## Windows 10 6 | 7 | Click on the Windows Start menu, then the Settings (gear icon). 8 | 9 | ![Start Settings](images/13startsettings.png) 10 | 11 | In the Windows 10 Settings window, type **environment** into the box at the top and select **Edit the system environment variables.** 12 | 13 | ![Settings](images/14settings.png) 14 | 15 | Click the **Environment Variables** button at the bottom of the page. 16 | 17 | ![Enviroment Variables](images/15environmentvariables.png) 18 | 19 | In the **Environment Variables** window, select **Path** in the bottom list (System variables) and click Edit. 20 | 21 | ![Edit](images/16edit.png) 22 | 23 | In the **Edit environment variable** window, click **New** then enter a new row in the table. In this example, I entered **C:\Program Files\dfu-util** but you should enter whatever path you want to add. It's OK for the path to contain spaces here. 24 | 25 | ![Edit New](images/17editnew.png) 26 | 27 | After editing the system path environment variable you'll probably need to restart the computer. 28 | 29 | 30 | 31 | ## Windows 7 and Windows 8 32 | 33 | You need to open the Control Panel. 34 | 35 | ![Open Control Panel](images/05controlpanel.png) 36 | 37 | And then click on **System and Security**. 38 | 39 | ![System and Security](images/06systemandsecurity.png) 40 | 41 | Then click **System**. 42 | 43 | ![System and Secury](images/18system.png) 44 | 45 | Then click on the **Advanced System Settings** link on the left side of the window. 46 | 47 | ![Advanced Settings](images/08advanced.png) 48 | 49 | Then click on **Environment Variables...** 50 | 51 | ![Environment](images/09environment.png) 52 | 53 | Click on **Path** in the bottom list (System variables) and click Edit. 54 | 55 | Finally, position the cursor at the end of the box and add the path you want to add. In this example, I entered **;C:\Program Files\dfu-util** but you should enter whatever path you want to add. 56 | 57 | There must be a semicolon separating the new item from the previous last item, and then the path to the directory we just created. It's OK for the path to contain spaces here. 58 | 59 | ![Edit variable](images/10editvar.png) 60 | 61 | After editing the system path environment variable you'll need to restart the computer or log out and log back in. 62 | 63 | ## Mac OS 64 | 65 | On the Mac, you edit the file ~/.profile, or the .profile in your home directory (such as /Users/rickk). 66 | 67 | On a completely new system you may need to create this file, otherwise just add the lines near the top of the file. 68 | 69 | For example, here's how I added the path /usr/local/bin/gcc-arm/bin: 70 | 71 | ``` 72 | # ARM gcc toolchain 73 | export PATH=$PATH:/usr/local/bin/gcc-arm/bin 74 | ``` 75 | 76 | Often you can just close all Terminal windows and reopen them, after making a .profile change. 77 | 78 | ## Linux 79 | 80 | On the Linux, you edit the file ~/.profile, or the .profile in your home directory (such as /home/rickk). 81 | 82 | Just add the lines near the top of the file. 83 | 84 | For example, here's how I added the path /usr/local/bin/gcc-arm/bin: 85 | 86 | ``` 87 | # ARM gcc toolchain 88 | export PATH=$PATH:/usr/local/bin/gcc-arm/bin 89 | ``` 90 | 91 | You may need to log out and log back in after editing your .profile. 92 | 93 | -------------------------------------------------------------------------------- /modifying-path/images/05controlpanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/05controlpanel.png -------------------------------------------------------------------------------- /modifying-path/images/06systemandsecurity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/06systemandsecurity.png -------------------------------------------------------------------------------- /modifying-path/images/08advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/08advanced.png -------------------------------------------------------------------------------- /modifying-path/images/09environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/09environment.png -------------------------------------------------------------------------------- /modifying-path/images/10editvar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/10editvar.png -------------------------------------------------------------------------------- /modifying-path/images/13startsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/13startsettings.png -------------------------------------------------------------------------------- /modifying-path/images/14settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/14settings.png -------------------------------------------------------------------------------- /modifying-path/images/15environmentvariables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/15environmentvariables.png -------------------------------------------------------------------------------- /modifying-path/images/16edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/16edit.png -------------------------------------------------------------------------------- /modifying-path/images/17editnew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/modifying-path/images/17editnew.png -------------------------------------------------------------------------------- /particle-cli-apple-silicon/README.md: -------------------------------------------------------------------------------- 1 | # Particle CLI on Apple Silicon (M1, M2, ...) 2 | 3 | Contrary to popular belief it is possible to use the Particle CLI on Apple silicon (M1, M2, ...) computers without using Rosetta (Intel emulation). 4 | 5 | ## Background 6 | 7 | ### Why do people think you need to use Rosetta 8 | 9 | When M1 computers were first released there were required packages that did not work properly on Apple silicon, but that's mostly not a problem now. 10 | 11 | If you try to install the Particle CLI using the Mac installer, it will warn you that you can't install it without Rosetta, but that's not entirely correct. 12 | 13 | There were no binaries for dfu-util for Apple silicon, but the CLI no longer needs dfu-util to flash binaries in DFU mode. 14 | 15 | ### Why do I want to run the CLI natively? 16 | 17 | 18 | ### Do I still need Rosetta? 19 | 20 | Yes. The 21 | 22 | Rosetta was a reasonable workaround, but running the tools in emulation is slower and now that essentially all new Macs are Apple silicon, it's time to bite the bullet and just make everything work natively. 23 | 24 | If you are starting from a clean computer, installation is relatively painless, but there are still some caveats. The biggest problems will occur if you've imported your Mac files from an Intel Mac. There are a number of steps that are necessary to correctly clean up Homebrew, node, and Workbench to get your 25 | 26 | 27 | 28 | ### Local build 29 | 30 | - Tools like `make` don't work 31 | -------------------------------------------------------------------------------- /particle-cli-repair/README.md: -------------------------------------------------------------------------------- 1 | # Particle CLI Repair 2 | 3 | If you get an error during Particle CLI installation or upgrade, or if you upgrade and the version remains unchanged at a lower version number, you may need to follow these steps to fix your Particle Command Line Interface install. 4 | 5 | ## Windows 6 | 7 | - Open a Command Prompt window and run the command: 8 | 9 | ``` 10 | npm uninstall -g particle-cli 11 | ``` 12 | 13 | If you get an error about npm not found, just continue onto the next step. This removes a previous manual install. 14 | 15 | - Download and run the [Particle CLI for Windows](https://binaries.particle.io/cli/installer/windows/ParticleCLISetup.exe) installer. 16 | 17 | There are additional tips [here](https://docs.particle.io/guide/tools-and-features/cli/). 18 | 19 | To upgrade the CLI, use the command: 20 | 21 | ``` 22 | particle upgrade-cli 23 | ``` 24 | 25 | ## Mac or Linux 26 | 27 | - Open a Terminal window and run the command: 28 | 29 | ``` 30 | sudo npm uninstall -g particle-cli 31 | ``` 32 | 33 | If you get an error about npm not found, just continue onto the next step. This removes a previous manual install. 34 | 35 | - Reinstall the CLI using the Particle CLI installer for Mac or Linux: 36 | 37 | ``` 38 | bash <( curl -sL https://particle.io/install-cli ) 39 | ``` 40 | 41 | - Check the version of the installed CLI. At the time of writing (April 10, 2018) it was 1.29.0. 42 | 43 | ``` 44 | particle --version 45 | ``` 46 | 47 | Make sure you do not use the `npm install -g particle-cli` or `npm update -g particle-cli` command as this will break your installation again. Instead, use: 48 | 49 | ``` 50 | particle upgrade-cli 51 | ``` 52 | 53 | The main difference between the Particle CLI installer and the old way is that the new way runs a separate copy of node.js just for the CLI, and also installs as the current user, instead of root. 54 | 55 | ### If you get an older version or particle command not found 56 | 57 | Check and see which particle you're finding: 58 | 59 | ``` 60 | which particle 61 | ``` 62 | 63 | If you get one in `/usr/local/bin/particle`, remove it: 64 | 65 | ``` 66 | sudo rm /usr/local/bin/particle 67 | ``` 68 | 69 | ### If you still get particle command not found 70 | 71 | Try reloading your .profile: 72 | 73 | ``` 74 | source ~/.profile 75 | ``` 76 | 77 | If that still does not solve the problem, double check that this is near the end of your ~/.profile file: 78 | 79 | ``` 80 | # set PATH so it includes user's private bin if it exists 81 | if [ -d "$HOME/bin" ] ; then 82 | PATH="$HOME/bin:$PATH" 83 | fi 84 | ``` 85 | 86 | -------------------------------------------------------------------------------- /particle-dev-tips/README.md: -------------------------------------------------------------------------------- 1 | # Particle Dev Tips 2 | 3 | Here are a few handy tips for using [Particle Dev](https://www.particle.io/products/development-tools/particle-local-ide), the Local IDE (Atom-based) for developing with the Particle Photon, Electron, etc. 4 | 5 | ## It does not build the open tab 6 | 7 | One thing that catches some people is that Particle Dev does not build the open tab. 8 | 9 | This setup, with three different programs in the src directory does not work, and produces the dreaded build didn't produce binary error: 10 | 11 | ![Multiple files](multifile.png) 12 | 13 | Even though blinkled.ino is the open tab, Particle Dev tries to build all of the files in the src directory (blinkled.ino, funcvar.ino and netleds.ino) together into a single program, which doesn't work because each is a complete, separate program with its own setup() and loop(). 14 | 15 | **Solution: Put each sketch/program in its own directory** 16 | 17 | ![One ino per folder](perfolder.png) 18 | 19 | ## It builds files in subdirectories, too 20 | 21 | Don't put other source, like different versions, broken code, etc. in a subdirectory because all of the files in subdirectories are compiled into your program, too. 22 | 23 | ![Subdirectories](subdirs.png) 24 | 25 | **Solution: Put other source in a different directory** 26 | 27 | 28 | 29 | 30 | ## Make sure you select your device 31 | 32 | Always make sure you have a device selected by clicking on **No devices selected** at the bottom of the window if it is displayed. 33 | 34 | ![No devices selected](nodevice.png) 35 | 36 | You can still build with no device selected, but it defaults to a Core. This means that features that require a Photon or Electron like [software timers](https://docs.particle.io/reference/firmware/photon/#software-timers) will cause a build didn't produce binary error. 37 | 38 | ![No devices selected using timer](timer.png) 39 | 40 | Once you select a Photon or Electron, this code will build properly. 41 | 42 | 43 | ## Build didn't produce binary 44 | 45 | In addition to the reasons above, a few other ways you can get a build didn't produce binary error include: 46 | 47 | ### Having files with both .ino and .cpp extensions 48 | 49 | In this case, the build failed because there were files LIS3DH.ino and LIS3DH.cpp. The solution is to rename LIS3DH.ino to something else, like LIS3DHTest.ino. 50 | 51 | ![ino and cpp files](inocpp.png) 52 | 53 | The reason is that during compile both LIS3DH.cpp and LIS3DH.ino produce an object file LIS3DH.o, and one overwrites the other. 54 | 55 | ### Using standard library function that's not implemented 56 | 57 | Using a standard C or C++ library function that's not supported can cause the build didn't produce binary error. 58 | 59 | ![missing function](missingfunction.png) 60 | 61 | And example of a more useful error message returned by the CLI is shown below. 62 | 63 | ### Program too large 64 | 65 | I think a program that is too large to fit in flash can cause this error as well. 66 | 67 | ## Electron flashes magenta after uploading binary 68 | 69 | Particle Dev always builds for the current released version of system firmware. This happens automatically in the cloud, even if you haven't upgraded your Particle Dev. 70 | 71 | This is not typically a problem with Photons as they automatically upgrade themselves to the matching system firmware version using the safe mode healer. 72 | 73 | Electrons, however, just go into safe mode (blinking magenta) because updating the Electron system firmware could use a lot of cellular data. In this case, the easiest solution is to upgrade the system firmware on the Electron. 74 | 75 | The information on the latest version of system firmware is on the [Particle Firmware Update Thread](https://community.particle.io/t/particle-firmware-updates-thread/14378/36). Note that Dev does not use the pre-release versions with "rc" in their version numbers. That page also has links for various ways to upgrade, including using the firmware manage and the CLI. 76 | 77 | Another option is to use the Particle CLI which allows you to choose which version of system firmware to build against. 78 | 79 | ## Using Particle CLI 80 | 81 | The [Particle CLI](https://docs.particle.io/guide/tools-and-features/cli/) (Command Line Interface) is handy tool to have. The link has information on it and installation instructions, so if you have not already installed it, it's useful to do so. 82 | 83 | One of the many features of the CLI is the ability to use the cloud compilers from the command line. These are the same compilers used by Particle Dev, but you can choose which system version to use, and also has much better error messages. 84 | 85 | In the example above, where the unimplemented time function was used, instead of "Build didn't produce binary" you get this: 86 | 87 | ``` 88 | C:\Users\IEUser\Documents\devtest5\timetest>particle compile photon timetest.ino Compiling code for photon Including: timetest.ino attempting to compile firmware Compile failed. Exiting. /usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7-m/libg_s.a(lib_a-gettimeofdayr.o): In function `_gettimeofday_r': gettimeofdayr.c:(.text._gettimeofday_r+0xe): undefined reference to `_gettimeofday' collect2: error: ld returned 1 exit status make: *** [39cf41e5f80ee901319f3c84199fbdb6d06f79f84e26c713e7b1b8030d8d.elf] Error 1 89 | ``` 90 | 91 | This is much more helpful! You can switch back and forth between compile in Dev vs. compiling using the CLI without problems. 92 | 93 | There are many options to the [particle compile](https://docs.particle.io/reference/cli/#compiling-remotely-and-flashing-locally) command explained in the documentation. 94 | 95 | I often use a command line that looks like this: 96 | 97 | ``` 98 | particle compile electron myprogram.ino --target 0.5.3 --saveTo firmware.bin 99 | ``` 100 | 101 | The options are: 102 | 103 | - electron: You need to specify the type of device you want to build for (core, photon, electron, or p1) 104 | - myprogram.ino: The source file to build. This can be multiple files or a directory as well. 105 | - --target 0.5.3: [optional] build for a specific system firmware version instead of the latest. This is useful if your Electron is not running the latest system firmware 106 | - --saveTo firmware.bin: [optional] give a specific filename to save the binary to. 107 | 108 | Once you have the firmware.bin file you can flash it using USB or over-the-air (OTA) using the particle flash CLI command. 109 | 110 | 111 | ## Compile in cloud does not always build 112 | 113 | In older versions, if you have a firmware.bin file already, edited the source, then used **Compile in cloud and upload using cloud** the old binary would be uploaded instead of recompiling. Now, in most cases, the firmware.bin file will be deleted automatically, but you may still find it useful to always do a **Compile in cloud and show errors if any** (1) first, then do a **Compile in cloud and upload using cloud** (2), just to be sure. 114 | 115 | ![Verify First](verifyfirst.png) 116 | 117 | 118 | ## Changes not saved (occasionally) 119 | 120 | This has been known to happen intermittently, at least on the Mac. It may have been fixed, because I haven't heard of it happening recently, but Command-S would occasionally not save files. You can tell because the blue dot next to the filename in the tab would not go away after saving. Selecting **Save All** from the menu would save and make the dot go away. 121 | 122 | ![Save indicator](saveindicator.png) 123 | 124 | 125 | -------------------------------------------------------------------------------- /particle-dev-tips/inocpp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/inocpp.png -------------------------------------------------------------------------------- /particle-dev-tips/missingfunction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/missingfunction.png -------------------------------------------------------------------------------- /particle-dev-tips/multifile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/multifile.png -------------------------------------------------------------------------------- /particle-dev-tips/nodevice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/nodevice.png -------------------------------------------------------------------------------- /particle-dev-tips/perfolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/perfolder.png -------------------------------------------------------------------------------- /particle-dev-tips/saveindicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/saveindicator.png -------------------------------------------------------------------------------- /particle-dev-tips/subdirs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/subdirs.png -------------------------------------------------------------------------------- /particle-dev-tips/timer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/timer.png -------------------------------------------------------------------------------- /particle-dev-tips/verifyfirst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/particle-dev-tips/verifyfirst.png -------------------------------------------------------------------------------- /photon-without-wifi/README.md: -------------------------------------------------------------------------------- 1 | # Using a Photon without Wi-Fi 2 | 3 | In its default configuration (system mode AUTOMATIC without system threading), the Photon requires a Wi-Fi connection to operate, and won't even run your user firmware. 4 | 5 | This is just the default configuration, however, and there are numerous ways to use the Photon without Wi-Fi or the cloud. 6 | 7 | ## Running with or without cloud 8 | 9 | The easiest way to make your code run whether you have Wi-Fi or a cloud connection is to use [SYSTEM\_THREAD](https://docs.particle.io/reference/firmware/#system-thread) mode. 10 | 11 | ``` 12 | SYSTEM_THREAD(ENABLED); 13 | ``` 14 | 15 | You insert this at the top of your source file. What it does is run the cloud processing in a separate system thread and your code will run regardless of whether you have a connection or not. 16 | 17 | The only thing to be careful is that when you do this, your loop code will run before connected to the cloud. Because of this, it's useful to check for a connection before publishing events: 18 | 19 | You might also do something like this in loop() when using [Particle.publish](https://docs.particle.io/reference/firmware/photon/#particle-publish-): 20 | 21 | ``` 22 | if (Particle.connected()) { 23 | Particle.publish("myEvent", PRIVATE); 24 | } 25 | ``` 26 | 27 | The same should be done for [Particle.subscribe](https://docs.particle.io/reference/firmware/photon/#particle-subscribe-). 28 | 29 | It's not necessary to check before [Particle.variable](https://docs.particle.io/reference/firmware/photon/#particle-variable-) or [Particle.function](https://docs.particle.io/reference/firmware/photon/#particle-function-). These should always be made early in setup() and should not wait for a cloud connection. 30 | 31 | ## Running with Wi-Fi off 32 | 33 | If you don't intend to use Wi-Fi at all, you can turn it off using the [MANUAL system mode](https://docs.particle.io/reference/firmware/photon/#manual-mode). 34 | 35 | ``` 36 | SYSTEM_MODE(MANUAL); 37 | ``` 38 | 39 | When you do this, the Photon will breathe white instead of cyan (light blue) and will not attempt to connect to the cloud. 40 | 41 | If you want to over-the-air (OTA) flash your Photon with new code, you can use [Safe Mode](https://docs.particle.io/guide/getting-started/modes/photon/#safe-mode). 42 | 43 | Press RESET and SETUP at the same time. Release RESET and continue to hold down SETUP until the status LED blinks magenta (red and blue at the same time). Release SETUP. 44 | 45 | Safe mode connects to the cloud but does not run your user firmware, so Wi-Fi and the cloud connection will stay on so you can do an OTA flash. 46 | 47 | ## Running with Wi-Fi but no cloud 48 | 49 | It's also possible to run the Photon with Wi-Fi enabled but no cloud connection. You might do this if you are using the Photon on an isolated network, not connected to the Internet, but you still have a Wi-Fi access point to connect to. 50 | 51 | This mode allows communication between devices on the local Wi-Fi network using [TCP](https://docs.particle.io/reference/firmware/photon/#tcpclient) or [UDP](https://docs.particle.io/reference/firmware/photon/#udp). You can't use things like [Particle.publish](https://docs.particle.io/reference/firmware/photon/#particle-publish-) without cloud access. 52 | 53 | To do this you'll probably use [SEMI\_AUTOMATIC system mode](https://docs.particle.io/reference/firmware/photon/#semi-automatic-mode), though sometimes you may prefer MANUAL. 54 | 55 | ``` 56 | SYSTEM_MODE(SEMI_AUTOMATIC); 57 | ``` 58 | 59 | In your setup() function, you'll probably use [WiFi.connect](https://docs.particle.io/reference/firmware/photon/#connect-). 60 | 61 | ``` 62 | WiFi.on(); 63 | WiFi.connect(); 64 | ``` 65 | 66 | This will connect Wi-Fi only, not the cloud, and you'll get breathing green instead of breathing cyan (light blue). 67 | 68 | ## Running with SoftAP 69 | 70 | In SoftAP mode, the Photon itself acts as a Wi-Fi access point. In this mode, another computer or phone can connect to the Photon Wi-Fi ("Photon-XXXX") and communicate data directly by using [TCP](https://docs.particle.io/reference/firmware/photon/#tcpclient) or [UDP](https://docs.particle.io/reference/firmware/photon/#udp). You can't use things like [Particle.publish](https://docs.particle.io/reference/firmware/photon/#particle-publish-) without cloud access. 71 | 72 | To do this, you'll need to use [SYSTEM\_THREAD](https://docs.particle.io/reference/firmware/#system-thread) mode. 73 | 74 | ``` 75 | SYSTEM_THREAD(ENABLED); 76 | ``` 77 | 78 | You'll also need to probably use [SEMI\_AUTOMATIC system mode](https://docs.particle.io/reference/firmware/photon/#semi-automatic-mode), though sometimes you may prefer MANUAL. 79 | 80 | ``` 81 | SYSTEM_MODE(SEMI_AUTOMATIC); 82 | ``` 83 | 84 | In your setup() function, you'll probably use [WiFi.listen](https://docs.particle.io/reference/firmware/photon/#listen-). 85 | 86 | ``` 87 | WiFi.on(); 88 | WiFi.listen(); 89 | ``` 90 | 91 | In listening mode, the Photon will blink dark blue. 92 | 93 | -------------------------------------------------------------------------------- /public-private-event-tips/images/01eventlog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/public-private-event-tips/images/01eventlog.png -------------------------------------------------------------------------------- /resetkeys_photon.md: -------------------------------------------------------------------------------- 1 | # Resetting keys - Photon 2 | 3 | For analysis purposes, it is helpful save a copy of the keys that are on the device before resetting them, so Particle can analyze them. 4 | 5 | Put the Photon in DFU mode (blinking yellow) by holding down the RESET and SETUP buttons, then release RESET and continue to hold down SETUP while it blinks magenta, then yellow, then release. 6 | 7 | Then enter each of these commands, one-by-one: 8 | 9 | ``` 10 | dfu-util -d 2b04:d006 -a 1 -s 2082:768 -U serverkey.bin 11 | particle keys server 12 | ``` 13 | 14 | Then reset it and see if it can connect to the cloud. If it works, please reply with the serverkey.bin and you can skip the remaining steps. 15 | 16 | Put the Photon in listening mode (blinking dark blue) by holding down the SETUP button until the main status LED blinks blue, then release. Then issue the command: 17 | 18 | ``` 19 | particle identify 20 | ``` 21 | 22 | Save the device ID that is returned; you'll need that next. 23 | 24 | Put the Photon back in DFU mode (blinking yellow) as above. And enter these commands, one-by-one: 25 | 26 | ``` 27 | dfu-util -d 2b04:d006 -a 1 -s 34:1216 -U devicepriv.bin 28 | dfu-util -d 2b04:d006 -a 1 -s 1250:384 -U devicepub.bin 29 | particle keys doctor YOUR_DEVICE_ID 30 | ``` 31 | 32 | replacing YOUR_DEVICE_ID with the 24-character hexadecimal identifier you got from Particle identify. Note that this is case-sensitive, all letters should be lowercase. 33 | 34 | Then reset your Photon and it should connect to the cloud. Normally you should not send your private key through an insecure channel like email, but since it was previously not valid, it should be okay in this case. 35 | 36 | If it does not connect to the cloud, you'll need to do a cloud debug; the instructions are here: 37 | 38 | [https://github.com/rickkas7/photon-clouddebug](https://github.com/rickkas7/photon-clouddebug) 39 | 40 | 41 | -------------------------------------------------------------------------------- /restoring-tinker/1ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/restoring-tinker/1ios.png -------------------------------------------------------------------------------- /restoring-tinker/2android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/restoring-tinker/2android.png -------------------------------------------------------------------------------- /restoring-tinker/README.md: -------------------------------------------------------------------------------- 1 | # Restoring Tinker 2 | 3 | The Tinker firmware is installed on Photon and Electron devices in the factory and allows you control the pins from the phone apps and from the cloud easily. While the intention is that you will replace it with your own firmware that you write, sometimes you may want to get it back. Fortunately, it's easy to do so! 4 | 5 | ## iOS phone app 6 | 7 | Using the iOS iPhone/iPad Particle app, select the device you want to reprogram. 8 | 9 | Then click the **...** in the upper right corner (1) and click the **Reflash Tinker** button (2). 10 | 11 | ![ios App](1ios.png) 12 | 13 | 14 | ## Android phone app 15 | 16 | Using the Android Particle app, select the device you want to reprogram. If it's not already running Tinker, you'll be presented with the option to **Reflash Tinker** right away. 17 | 18 | ![Android App](2android.png) 19 | 20 | ## Particle CLI 21 | 22 | Installing the [Particle CLI](https://docs.particle.io/guide/tools-and-features/cli/photon/) is good idea because you will eventually find it useful as you develop with your Photon or Electron. 23 | 24 | If you have it installed, put the device in DFU mode (blinking yellow) by holding down the SETUP and RESET buttons. Release RESET and continue to hold down SETUP while the main status LED blinks magenta, until it blinks yellow, then release SETUP. 25 | 26 | (If you're using an Electron or Core, the button is labeled MODE, not SETUP, but it functions in the same way.) 27 | 28 | Then enter the CLI command: 29 | 30 | ``` 31 | particle flash --usb tinker 32 | ``` 33 | 34 | If you get an error that dfu-util is not installed, you can either [install DFU util](https://github.com/rickkas7/particle_notes/tree/master/installing-dfu-util) or follow these alternate instructions: 35 | 36 | Press and release RESET. Then hold down SETUP (or MODE) until the main status LED blinks dark blue. Then issue the command: 37 | 38 | ``` 39 | particle flash --serial tinker 40 | ``` 41 | 42 | The --usb option is preferable, unless you are having trouble with your DFU installation. 43 | 44 | ## By flashing it manually 45 | 46 | You can also just copy and paste Tinker into your build environment and flash it to your device. Here's the source: 47 | 48 | ``` 49 | /* Function prototypes -------------------------------------------------------*/ 50 | int tinkerDigitalRead(String pin); 51 | int tinkerDigitalWrite(String command); 52 | int tinkerAnalogRead(String pin); 53 | int tinkerAnalogWrite(String command); 54 | 55 | SYSTEM_MODE(AUTOMATIC); 56 | 57 | /* This function is called once at start up ----------------------------------*/ 58 | void setup() 59 | { 60 | //Setup the Tinker application here 61 | 62 | //Register all the Tinker functions 63 | Particle.function("digitalread", tinkerDigitalRead); 64 | Particle.function("digitalwrite", tinkerDigitalWrite); 65 | 66 | Particle.function("analogread", tinkerAnalogRead); 67 | Particle.function("analogwrite", tinkerAnalogWrite); 68 | } 69 | 70 | /* This function loops forever --------------------------------------------*/ 71 | void loop() 72 | { 73 | //This will run in a loop 74 | } 75 | 76 | /******************************************************************************* 77 | * Function Name : tinkerDigitalRead 78 | * Description : Reads the digital value of a given pin 79 | * Input : Pin 80 | * Output : None. 81 | * Return : Value of the pin (0 or 1) in INT type 82 | Returns a negative number on failure 83 | *******************************************************************************/ 84 | int tinkerDigitalRead(String pin) 85 | { 86 | //convert ascii to integer 87 | int pinNumber = pin.charAt(1) - '0'; 88 | //Sanity check to see if the pin numbers are within limits 89 | if (pinNumber < 0 || pinNumber > 7) return -1; 90 | 91 | if(pin.startsWith("D")) 92 | { 93 | pinMode(pinNumber, INPUT_PULLDOWN); 94 | return digitalRead(pinNumber); 95 | } 96 | else if (pin.startsWith("A")) 97 | { 98 | pinMode(pinNumber+10, INPUT_PULLDOWN); 99 | return digitalRead(pinNumber+10); 100 | } 101 | #if Wiring_Cellular 102 | else if (pin.startsWith("B")) 103 | { 104 | if (pinNumber > 5) return -3; 105 | pinMode(pinNumber+24, INPUT_PULLDOWN); 106 | return digitalRead(pinNumber+24); 107 | } 108 | else if (pin.startsWith("C")) 109 | { 110 | if (pinNumber > 5) return -4; 111 | pinMode(pinNumber+30, INPUT_PULLDOWN); 112 | return digitalRead(pinNumber+30); 113 | } 114 | #endif 115 | return -2; 116 | } 117 | 118 | /******************************************************************************* 119 | * Function Name : tinkerDigitalWrite 120 | * Description : Sets the specified pin HIGH or LOW 121 | * Input : Pin and value 122 | * Output : None. 123 | * Return : 1 on success and a negative number on failure 124 | *******************************************************************************/ 125 | int tinkerDigitalWrite(String command) 126 | { 127 | bool value = 0; 128 | //convert ascii to integer 129 | int pinNumber = command.charAt(1) - '0'; 130 | //Sanity check to see if the pin numbers are within limits 131 | if (pinNumber < 0 || pinNumber > 7) return -1; 132 | 133 | if(command.substring(3,7) == "HIGH") value = 1; 134 | else if(command.substring(3,6) == "LOW") value = 0; 135 | else return -2; 136 | 137 | if(command.startsWith("D")) 138 | { 139 | pinMode(pinNumber, OUTPUT); 140 | digitalWrite(pinNumber, value); 141 | return 1; 142 | } 143 | else if(command.startsWith("A")) 144 | { 145 | pinMode(pinNumber+10, OUTPUT); 146 | digitalWrite(pinNumber+10, value); 147 | return 1; 148 | } 149 | #if Wiring_Cellular 150 | else if(command.startsWith("B")) 151 | { 152 | if (pinNumber > 5) return -4; 153 | pinMode(pinNumber+24, OUTPUT); 154 | digitalWrite(pinNumber+24, value); 155 | return 1; 156 | } 157 | else if(command.startsWith("C")) 158 | { 159 | if (pinNumber > 5) return -5; 160 | pinMode(pinNumber+30, OUTPUT); 161 | digitalWrite(pinNumber+30, value); 162 | return 1; 163 | } 164 | #endif 165 | else return -3; 166 | } 167 | 168 | /******************************************************************************* 169 | * Function Name : tinkerAnalogRead 170 | * Description : Reads the analog value of a pin 171 | * Input : Pin 172 | * Output : None. 173 | * Return : Returns the analog value in INT type (0 to 4095) 174 | Returns a negative number on failure 175 | *******************************************************************************/ 176 | int tinkerAnalogRead(String pin) 177 | { 178 | //convert ascii to integer 179 | int pinNumber = pin.charAt(1) - '0'; 180 | //Sanity check to see if the pin numbers are within limits 181 | if (pinNumber < 0 || pinNumber > 7) return -1; 182 | 183 | if(pin.startsWith("D")) 184 | { 185 | return -3; 186 | } 187 | else if (pin.startsWith("A")) 188 | { 189 | return analogRead(pinNumber+10); 190 | } 191 | #if Wiring_Cellular 192 | else if (pin.startsWith("B")) 193 | { 194 | if (pinNumber < 2 || pinNumber > 5) return -3; 195 | return analogRead(pinNumber+24); 196 | } 197 | #endif 198 | return -2; 199 | } 200 | 201 | /******************************************************************************* 202 | * Function Name : tinkerAnalogWrite 203 | * Description : Writes an analog value (PWM) to the specified pin 204 | * Input : Pin and Value (0 to 255) 205 | * Output : None. 206 | * Return : 1 on success and a negative number on failure 207 | *******************************************************************************/ 208 | int tinkerAnalogWrite(String command) 209 | { 210 | String value = command.substring(3); 211 | 212 | if(command.substring(0,2) == "TX") 213 | { 214 | pinMode(TX, OUTPUT); 215 | analogWrite(TX, value.toInt()); 216 | return 1; 217 | } 218 | else if(command.substring(0,2) == "RX") 219 | { 220 | pinMode(RX, OUTPUT); 221 | analogWrite(RX, value.toInt()); 222 | return 1; 223 | } 224 | 225 | //convert ascii to integer 226 | int pinNumber = command.charAt(1) - '0'; 227 | //Sanity check to see if the pin numbers are within limits 228 | 229 | if (pinNumber < 0 || pinNumber > 7) return -1; 230 | 231 | if(command.startsWith("D")) 232 | { 233 | pinMode(pinNumber, OUTPUT); 234 | analogWrite(pinNumber, value.toInt()); 235 | return 1; 236 | } 237 | else if(command.startsWith("A")) 238 | { 239 | pinMode(pinNumber+10, OUTPUT); 240 | analogWrite(pinNumber+10, value.toInt()); 241 | return 1; 242 | } 243 | else if(command.substring(0,2) == "TX") 244 | { 245 | pinMode(TX, OUTPUT); 246 | analogWrite(TX, value.toInt()); 247 | return 1; 248 | } 249 | else if(command.substring(0,2) == "RX") 250 | { 251 | pinMode(RX, OUTPUT); 252 | analogWrite(RX, value.toInt()); 253 | return 1; 254 | } 255 | #if Wiring_Cellular 256 | else if (command.startsWith("B")) 257 | { 258 | if (pinNumber > 3) return -3; 259 | pinMode(pinNumber+24, OUTPUT); 260 | analogWrite(pinNumber+24, value.toInt()); 261 | return 1; 262 | } 263 | else if (command.startsWith("C")) 264 | { 265 | if (pinNumber < 4 || pinNumber > 5) return -4; 266 | pinMode(pinNumber+30, OUTPUT); 267 | analogWrite(pinNumber+30, value.toInt()); 268 | return 1; 269 | } 270 | #endif 271 | else return -2; 272 | } 273 | ``` 274 | -------------------------------------------------------------------------------- /safemode.md: -------------------------------------------------------------------------------- 1 | # Safe mode explained 2 | 3 | The Particle Photon, P1, and Electron support safe mode, breathing magenta. 4 | 5 | Safe mode allows network connectivity but does not run your user firmware. This is most useful when you want to OTA (over-the-air) cloud flash code to your device but: 6 | 7 | - You have a program that runs with the cloud connection turned off 8 | - Your program uses sleep mode to save power 9 | - You have a bug in your code that prevents cloud access (breathing green) 10 | 11 | ## Entering Safe Mode (Photon) 12 | 13 | You enter safe mode by holding down RESET and SETUP, releasing RESET and continuing to hold down SETUP until the main status LED blinks magenta, then release. 14 | 15 | Because Safe Mode requires Wi-Fi, the Photon will then go through the normal states: blinking white, blinking green, fast blinking green, blinking cyan, fast blinking cyan, except the last state will be breathing magenta, instead of breathing cyan. 16 | 17 | If you have something that's preventing Wi-Fi access, such a Wi-Fi access point problem or a configuration problem, safe mode won't help. It's not designed for that; it's designed to allow OTA flashing. 18 | 19 | ## Entering Safe Mode (Electron) 20 | 21 | You enter safe mode by holding down RESET and MODE, releasing RESET and continuing to hold down MODE until the main status LED blinks magenta, then release. 22 | 23 | Because Safe Mode requires a cellular connection, the Electron will then go through the normal states: blinking white, blinking green, fast blinking green, blinking cyan, fast blinking cyan, except the last state will be breathing magenta, instead of breathing cyan. 24 | 25 | If you have something that's preventing cellular access, such a bad cellular signal, antenna problems, or an SIM activation problem, safe mode won't help. It's not designed for that; it's designed to allow OTA flashing. 26 | 27 | ## Safe mode (blinking magenta) 28 | 29 | On the Electron, sometimes when you flash user firmware over USB, the Electron will enter safe mode (blinking magenta). This is typically caused by a user firmware and system firmware mismatch. A slightly different thing happens with the Photon, see the Safe mode healer section, below. 30 | 31 | When you build user firmware, it contains not only the code you have written, but also some parts that communicate with the system firmware. It also lists the minimum system firmware that your firmware will run on. For example, the Particle.keepAlive() call was added in 0.5.0. If you use that call from your code, you can't run your code on 0.4.8 because the system side of that code does not exist. 32 | 33 | ### Particle Build (Web IDE) 34 | Click on the Devices icon on the left-hand side (the circle with 4 lines, the target icon). Make sure your device has a gold star to the left of its name. When you click on the arrow, it will expand with an area including the device ID and a popup menu for the system firmware version to build with. 35 | 36 | You can also use Particle Build to make binary files that you can flash using USB to an Electron. Click on the Code icon (the <> icon). The cloud icon to the right and slightly above your project name allows you to download a firmware binary file. 37 | 38 | ### Particle Dev (Atom IDE) 39 | Particle Dev can only build for the most recent release version of the Particle Firmware. The easiest solution is to upgrade the system firmware on your Electron. Or you can use Particle Dev as the editor, and use the Particle CLI to compile. 40 | 41 | Note that the release version is one without a "rc" in the version. For example, if there is an 0.5.2 and an 0.5.3-rc1, then Particle Dev will use 0.5.2. The releases are documented on the [Particle Firmware Update Thread] (https://community.particle.io/t/particle-firmware-update-thread/14378/33). 42 | 43 | 44 | ### Particle CLI 45 | The Particle CLI defaults to compiling with the most recent release version of the Particle Firmware. You, can, however, change the setting using the command line. 46 | 47 | ``` 48 | particle compile electron myprogram.ino --target 0.4.8 --saveTo firmware.bin 49 | particle flash --usb firmware.bin 50 | ``` 51 | 52 | There's more information in the [CLI documentation] (https://docs.particle.io/reference/cli/#particle-flash). 53 | 54 | 55 | ## Safe mode healer 56 | 57 | The process in the previous section was kind of a pain, so on the Photon/P1 the safe mode healer is used. If the Photon detects a newer system firmware version is required, it will automatically download and install the newer system firmware. Fast blinking magenta indicates that this is occurring, and typically two bouts of fast blinking magenta occur, one for each system part. 58 | 59 | On regular Electrons this is not done, because it could use a lot of data accidentally downloading system firmware. Also, it could take a while over 2G. 60 | 61 | On Electrons that are part of a product creator product, safe mode healer is enabled. The logic there is that if you release firmware from the product dashboard, you presumably would know it's about to kick off a possibly expensive operation. This also provides an easy way to upgrade the system firmware many remote Electrons at once, with a single click. 62 | 63 | 64 | ## About breathing green 65 | 66 | If your program is breathing cyan normally, then switches to breathing green, you are probably blocking cloud processing. When in breathing green state, you won't be able to OTA cloud flash, but you can use safe mode (breathing magenta) to cloud flash new code. 67 | 68 | For example, this program will breathe cyan for about 10 seconds then breathe green and stop responding to the cloud. **Don't do this:** 69 | 70 | ``` 71 | void setup() { 72 | } 73 | 74 | void loop() { 75 | // Don't do this! It causes blinking green because you've blocked 76 | // loop from returning. 77 | while(true) { 78 | } 79 | } 80 | ``` 81 | 82 | The correct solution is to remove that inner while loop. Or you can add [Particle.process()] (https://docs.particle.io/reference/firmware/electron/#particle-process-) calls in any inner loops that block loop(). 83 | 84 | ### Using system thread 85 | 86 | Another way to solve this problem is to use [SYSTEM_THREAD(ENABLED)] (https://docs.particle.io/reference/firmware/electron/#system-thread). This separates the cloud processing code from your user code, so you're less likely to interfere with it. 87 | 88 | ``` 89 | SYSTEM_THREAD(ENABLED); 90 | 91 | void setup() { 92 | // OK to do things like Particle.function and Particle.variable here 93 | 94 | // If you do any Particle.publish in setup(), do this too: 95 | waitUntil(Particle.connected); 96 | Particle.publish("testEvent", "testing", PRIVATE); 97 | } 98 | 99 | void loop() { 100 | } 101 | ``` 102 | 103 | -------------------------------------------------------------------------------- /setting-up-asset-tracker-in-build/1-select-library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/setting-up-asset-tracker-in-build/1-select-library.png -------------------------------------------------------------------------------- /setting-up-asset-tracker-in-build/2-select-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/setting-up-asset-tracker-in-build/2-select-example.png -------------------------------------------------------------------------------- /setting-up-asset-tracker-in-build/3-use-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/setting-up-asset-tracker-in-build/3-use-example.png -------------------------------------------------------------------------------- /setting-up-asset-tracker-in-build/4-device.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/setting-up-asset-tracker-in-build/4-device.png -------------------------------------------------------------------------------- /setting-up-asset-tracker-in-build/5-verify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/setting-up-asset-tracker-in-build/5-verify.png -------------------------------------------------------------------------------- /setting-up-asset-tracker-in-build/README.md: -------------------------------------------------------------------------------- 1 | # Setting up AssetTracker in Build 2 | 3 | - Click the **Libraries** icon (1) 4 | - Select **ASSETTRACKER** (2) 5 | 6 | ![Select Library](1-select-library.png) 7 | 8 | - Select **1\_GPS\_FEATURES.CPP** (3) 9 | 10 | ![Select Example](2-select-example.png) 11 | 12 | - Select **USE THIS EXAMPLE** (4) 13 | 14 | ![Use Example](3-use-example.png) 15 | 16 | - Click the Devices icon, the circle with 4 lines (5) 17 | - Make sure your Electron has a gold star to the left of it. If not, click the name. 18 | - Click the <> icon to go back to your code. 19 | 20 | ![Select Device](4-device.png) 21 | 22 | - Click the **Verify** button to test the code 23 | 24 | ![Verify](5-verify.png) 25 | -------------------------------------------------------------------------------- /setting-up-out-of-area-electron/README.md: -------------------------------------------------------------------------------- 1 | # Setting up an out-of-area Electron 2 | 3 | The Particle Electron comes in three varieties, global 2G (G350), and two varieties of 3G: U260 (Americas/Australia) and U270 (Europe/Asia/Africa). 4 | 5 | This note explains how to set up a Electron that you want to ship to another location, such as for a demo. For example, you want to set up a U270 in the United States for a demo in Europe. 6 | 7 | This technique also applies in areas where 2G is no longer supported, for example if you wanted to set up a 2G Electron in Japan for shipment to Europe. 8 | 9 | ## Particle SIM card 10 | 11 | The Particle SIM card is global. You can set up the SIM in one location and use it in another location. 12 | 13 | The [billing guide](https://docs.particle.io/guide/getting-started/billing/electron/) has additional information, but you have a home zone, say the United States (US$0.99/megabyte). If you travel to India, it's in a different zone with a different rate (US$2.99/megabyte). You'll initially be charged the $2.99 for the first megabyte of data in India, and the data usage there will be counted separately from your US data usage. 14 | 15 | If you want to set up the SIM card ahead of time you can use the right-side option at [https://setup.particle.io](https://setup.particle.io) to activate only the Particle SIM card. 16 | 17 | You can also set up the SIM from the setup web site when you get there, of course. 18 | 19 | ## Electron 20 | 21 | Here's where things get a little trickier. You need to be online (breathing cyan) in order to complete the claiming process. This is impossible when you have an out-of-area Electron. 22 | 23 | Fortunately, you can still load code by USB before the Electron has been claimed. So, for example, you could use the [Particle CLI](https://particle.io/cli) command: 24 | 25 | ``` 26 | particle flash --usb firmware.bin 27 | ``` 28 | 29 | Using this technique you can preload your code. You can also update the system firmware, if desired. 30 | 31 | This is also a good time to note the device ID and ICCID, since you may need them later. 32 | 33 | Connect the device to your computer using USB and put the device in [listening mode](https://docs.particle.io/guide/getting-started/modes/electron/#listening-mode) (blinking dark blue) by holding down the SETUP (or MODE) button until the main status LED blinks dark blue, about 3 seconds. 34 | 35 | Then issue the command: 36 | 37 | ``` 38 | particle identify 39 | ``` 40 | 41 | This will print out your device ID and ICCID. 42 | 43 | 44 | ## The final step 45 | 46 | Once the device reaches its actual location it will now have your code, and a SIM that should allow it to get online, breathing cyan. So power it up in the demo location, wait for it to reach breathing cyan, and then claim it. 47 | 48 | This can be using the command line: 49 | 50 | ``` 51 | particle device add YOUR_DEVICE_ID 52 | ``` 53 | 54 | You can even do it remotely, issuing the command from the United States for the device in Europe. 55 | 56 | You can also claim a device by its device ID from [https://build.particle.io](https://build.particle.io), or you can use Particle phone apps, if desired. 57 | 58 | If you're in a remote location and you've forgotten your device ID and don't have access to a laptop with the Particle CLI, here are some [other ways you can get the device ID](https://community.particle.io/t/finding-your-device-id/26531). 59 | -------------------------------------------------------------------------------- /system-source-and-headers/README.md: -------------------------------------------------------------------------------- 1 | # System Source and Header Files 2 | 3 | While the [official system firmware documentation](https://docs.particle.io/reference/firmware) has a lot of information, sometimes you want to see more details, like the header files and source. 4 | 5 | ## System Firmware 6 | 7 | The system firmware is open source and is available here: [https://github.com/spark/firmware](https://github.com/spark/firmware). 8 | 9 | I recommend downloading a specific release, rather than develop. For example you could select the branch "release/v0.6.0" to get the released version of the 0.6.0 firmware. Then just download the zip or clone from Github. 10 | 11 | The header files and implementation for most of the APIs, things like String, TCPClient, System, and Particle classes are in the wiring directory. 12 | 13 | There are some other things scattered about in other directories as well, so if you can't find something, you can try searching the entire firmware directory. 14 | 15 | ## C/C++ Standard Includes 16 | 17 | One thing that's not included above are the standard C/C++ includes, things like string.h and stdlib.h. These are provided by the compiler toolset and are not part of the firmware repository. 18 | 19 | They are pretty standard gcc 4.9 includes running in C++11 mode so you probably use resources like [cplusplus.com](http://www.cplusplus.com), however if you download and install the gcc-arm build chain, you'll then be able to search the include in the location you downloaded it to. 20 | 21 | The instructions for installing the local gcc-arm build chain are here: 22 | [https://docs.particle.io/faq/particle-tools/local-build](https://docs.particle.io/faq/particle-tools/local-build). 23 | -------------------------------------------------------------------------------- /tinker-apn-tips/README.md: -------------------------------------------------------------------------------- 1 | # Tinker with APN tips for Electron 2 | 3 | Every firmware binary you run on your Electron with a 3rd-party SIM card must have the lines of code that set the APN and typically the keep-alive value. This is explained in detail in the [3rd-party SIM guide](https://docs.particle.io/faq/particle-devices/electron-3rdparty-sims/electron/) however this note is for help with flashing your first APN setting code. 4 | 5 | The default firmware on the Electron from the factory is Tinker, and allows to do simple thing like change the state of the pins from the mobile apps. The caveat is that it does not work with 3rd-party SIM cards. You can fix this by flashing Tinker with APN firmware. 6 | 7 | ## Getting Started 8 | 9 | If you have not done so already, please install the Particle CLI. The command line utilities are useful not only for solving this problem but will be valuable later on, as well. 10 | 11 | [https://docs.particle.io/guide/tools-and-features/cli](https://docs.particle.io/guide/tools-and-features/cli) 12 | 13 | If you are using Windows, be sure to use the link to [Windows CLI Installer](https://binaries.particle.io/cli/installer/windows/ParticleCLISetup.exe) that will automatically install all of the components instead of the more complicated manual install. 14 | 15 | 16 | ## Method 1: setup.particle.io 17 | 18 | Once way to get a Tinker with APN binary is to go through the setup process at [https://setup.particle.io](https://setup.particle.io). Select the left option (Electron with SIM card) and enter the ICCID of your 3rd-party SIM card. You should be directed to the non-Particle SIM card page: 19 | 20 | ![Setup](images/setup3rdparty.png) 21 | 22 | Follow the instructions on the page to flash your Electron with Tinker with APN setting. 23 | 24 | ## Method 2: Particle Build (Web IDE) 25 | 26 | You can build your own version of Tinker with APN setting using Particle Build (Web IDE). This is handy because it allows you to tweak more settings. 27 | 28 | - You can use [this link](https://go.particle.io/shared_apps/595d351dd3deccba2100013c) to open a shared version of the Tinker with APN app. 29 | 30 | Or, if you prefer, you can open [tinker-apn.cpp](https://raw.githubusercontent.com/rickkas7/particle_notes/master/tinker-apn-tips/tinker-apn.cpp) and copy and paste it into a new app. 31 | 32 | - Edit line 5 that begins with `STARTUP` to set the APN for your cellular provider. The example has fast.t-mobile.com; replace that with your APN. 33 | 34 | ``` 35 | STARTUP(cellular_credentials_set("fast.tmobile.com", "", "", NULL)); 36 | ``` 37 | 38 | - Line 21 has a call to `Particle.keepAlive`. The keep-alive is explained in the [3rd-party SIM guide](https://docs.particle.io/faq/particle-devices/electron-3rdparty-sims/electron/). If you have not upgraded your Electron system firmware, you should comment out this line or you will get a compile error. 39 | 40 | ``` 41 | Particle.keepAlive(120); 42 | ``` 43 | 44 | - Or, even better, upgrade your Electron. Hold down RESET and MODE, release RESET and continue to hold down MODE while the status LED blinks magenta until it blinks yellow, then release MODE. Then enter the command in a Command Prompt (for Windows) or Terminal (for Mac or Linux) window: 45 | 46 | ``` 47 | particle update 48 | ``` 49 | 50 | - Click on the Devices icon (circle with 4 lines) and make sure your Electron is selected. 51 | 52 | - Click on the Code icon (<>). Then click on the cloud icon to the right of the project name. 53 | 54 | ![Cloud Icon](images/cloud-icon.png) 55 | 56 | This will download the firmware to your Internet Downloads directory. 57 | 58 | - Hold down RESET and MODE, release RESET and continue to hold down MODE while the status LED blinks magenta until it blinks yellow, then release MODE. Then enter the command in a Command Prompt (for Windows) or Terminal (for Mac or Linux) window: 59 | 60 | ``` 61 | cd Downloads 62 | particle flash --usb firmware.bin 63 | ``` 64 | 65 | If you've downloaded firmware before, the name may be different. If it contains spaces, enclose the name in double quotes, like this: 66 | 67 | ``` 68 | particle flash --usb "firmware (1).bin" 69 | ``` 70 | 71 | - If you get an error that dfu-util is not found, you should [install it](https://docs.particle.io/faq/particle-tools/installing-dfu-util/electron/). However you can use the alternate method of installation until you do: Reset the Electron. Then hold down the MODE button until the status LED blinks dark blue. Then issue the command: 72 | 73 | ``` 74 | particle flash --serial firmware.bin 75 | ``` 76 | 77 | 78 | ## Method 3: Particle CLI 79 | 80 | - Download the [tinker-apn.cpp](https://raw.githubusercontent.com/rickkas7/particle_notes/master/tinker-apn-tips/tinker-apn.cpp) file. 81 | 82 | - Hold down RESET and MODE, release RESET and continue to hold down MODE while the status LED blinks magenta until it blinks yellow, then release MODE. 83 | 84 | - If you have not upgraded your Electron system firmware from the factory default, you should do so by doing: 85 | 86 | ``` 87 | particle update 88 | ``` 89 | 90 | - Edit line 5 of tinker-apn.cpp that begins with `STARTUP` to set the APN for your cellular provider. The example has fast.t-mobile.com; replace that with your APN. 91 | 92 | - Line 21 has a call to `Particle.keepAlive`. The keep-alive is explained in the [3rd-party SIM guide](https://docs.particle.io/faq/particle-devices/electron-3rdparty-sims/electron/). If you have not upgraded your Electron system firmware, you should comment out this line or you will get a compile error. 93 | 94 | - Then build and flash Tinker with APN. Make sure the Electron is blinking yellow before you use the flash command. 95 | 96 | ``` 97 | cd Downloads 98 | particle compile electron tinker-apn.cpp --saveTo tinker-apn.bin 99 | particle flash --usb tinker-apn.bin 100 | ``` 101 | 102 | - If you get an error that dfu-util is not found, you should [install it](https://docs.particle.io/faq/particle-tools/installing-dfu-util/electron/). However you can use the alternate method of installation until you do: Reset the Electron. Then hold down the MODE button until the status LED blinks dark blue. Then issue the command: 103 | 104 | ``` 105 | particle flash --serial tinker-apn.bin 106 | ``` 107 | 108 | - If you don't want to upgrade your Electron system firmware, you must target the the earlier version, for example: 109 | 110 | ``` 111 | particle compile electron tinker-apn.cpp --target 0.4.8 --saveTo tinker-apn.bin 112 | ``` 113 | 114 | -------------------------------------------------------------------------------- /tinker-apn-tips/images/cloud-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/tinker-apn-tips/images/cloud-icon.png -------------------------------------------------------------------------------- /tinker-apn-tips/images/setup3rdparty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/tinker-apn-tips/images/setup3rdparty.png -------------------------------------------------------------------------------- /tinker-apn-tips/tinker-apn.cpp: -------------------------------------------------------------------------------- 1 | #include "Particle.h" 2 | 3 | // Set your 3rd-party SIM APN here 4 | // https://docs.particle.io/reference/firmware/electron/#setcredentials- 5 | STARTUP(cellular_credentials_set("fast.tmobile.com", "", "", NULL)); 6 | 7 | 8 | /* Function prototypes -------------------------------------------------------*/ 9 | int tinkerDigitalRead(String pin); 10 | int tinkerDigitalWrite(String command); 11 | int tinkerAnalogRead(String pin); 12 | int tinkerAnalogWrite(String command); 13 | 14 | SYSTEM_MODE(AUTOMATIC); 15 | 16 | /* This function is called once at start up ----------------------------------*/ 17 | void setup() 18 | { 19 | // Set the keep-alive value for 3rd party SIM card here 20 | // https://docs.particle.io/reference/firmware/electron/#particle-keepalive- 21 | // Note: Requires system firmware 0.5.0 or later 22 | Particle.keepAlive(120); 23 | 24 | //Setup the Tinker application here 25 | 26 | //Register all the Tinker functions 27 | Particle.function("digitalread", tinkerDigitalRead); 28 | Particle.function("digitalwrite", tinkerDigitalWrite); 29 | 30 | Particle.function("analogread", tinkerAnalogRead); 31 | Particle.function("analogwrite", tinkerAnalogWrite); 32 | } 33 | 34 | /* This function loops forever --------------------------------------------*/ 35 | void loop() 36 | { 37 | //This will run in a loop 38 | } 39 | 40 | /******************************************************************************* 41 | * Function Name : tinkerDigitalRead 42 | * Description : Reads the digital value of a given pin 43 | * Input : Pin 44 | * Output : None. 45 | * Return : Value of the pin (0 or 1) in INT type 46 | Returns a negative number on failure 47 | *******************************************************************************/ 48 | int tinkerDigitalRead(String pin) 49 | { 50 | //convert ascii to integer 51 | int pinNumber = pin.charAt(1) - '0'; 52 | //Sanity check to see if the pin numbers are within limits 53 | if (pinNumber < 0 || pinNumber > 7) return -1; 54 | 55 | if(pin.startsWith("D")) 56 | { 57 | pinMode(pinNumber, INPUT_PULLDOWN); 58 | return digitalRead(pinNumber); 59 | } 60 | else if (pin.startsWith("A")) 61 | { 62 | pinMode(pinNumber+10, INPUT_PULLDOWN); 63 | return digitalRead(pinNumber+10); 64 | } 65 | #if Wiring_Cellular 66 | else if (pin.startsWith("B")) 67 | { 68 | if (pinNumber > 5) return -3; 69 | pinMode(pinNumber+24, INPUT_PULLDOWN); 70 | return digitalRead(pinNumber+24); 71 | } 72 | else if (pin.startsWith("C")) 73 | { 74 | if (pinNumber > 5) return -4; 75 | pinMode(pinNumber+30, INPUT_PULLDOWN); 76 | return digitalRead(pinNumber+30); 77 | } 78 | #endif 79 | return -2; 80 | } 81 | 82 | /******************************************************************************* 83 | * Function Name : tinkerDigitalWrite 84 | * Description : Sets the specified pin HIGH or LOW 85 | * Input : Pin and value 86 | * Output : None. 87 | * Return : 1 on success and a negative number on failure 88 | *******************************************************************************/ 89 | int tinkerDigitalWrite(String command) 90 | { 91 | bool value = 0; 92 | //convert ascii to integer 93 | int pinNumber = command.charAt(1) - '0'; 94 | //Sanity check to see if the pin numbers are within limits 95 | if (pinNumber < 0 || pinNumber > 7) return -1; 96 | 97 | if(command.substring(3,7) == "HIGH") value = 1; 98 | else if(command.substring(3,6) == "LOW") value = 0; 99 | else return -2; 100 | 101 | if(command.startsWith("D")) 102 | { 103 | pinMode(pinNumber, OUTPUT); 104 | digitalWrite(pinNumber, value); 105 | return 1; 106 | } 107 | else if(command.startsWith("A")) 108 | { 109 | pinMode(pinNumber+10, OUTPUT); 110 | digitalWrite(pinNumber+10, value); 111 | return 1; 112 | } 113 | #if Wiring_Cellular 114 | else if(command.startsWith("B")) 115 | { 116 | if (pinNumber > 5) return -4; 117 | pinMode(pinNumber+24, OUTPUT); 118 | digitalWrite(pinNumber+24, value); 119 | return 1; 120 | } 121 | else if(command.startsWith("C")) 122 | { 123 | if (pinNumber > 5) return -5; 124 | pinMode(pinNumber+30, OUTPUT); 125 | digitalWrite(pinNumber+30, value); 126 | return 1; 127 | } 128 | #endif 129 | else return -3; 130 | } 131 | 132 | /******************************************************************************* 133 | * Function Name : tinkerAnalogRead 134 | * Description : Reads the analog value of a pin 135 | * Input : Pin 136 | * Output : None. 137 | * Return : Returns the analog value in INT type (0 to 4095) 138 | Returns a negative number on failure 139 | *******************************************************************************/ 140 | int tinkerAnalogRead(String pin) 141 | { 142 | //convert ascii to integer 143 | int pinNumber = pin.charAt(1) - '0'; 144 | //Sanity check to see if the pin numbers are within limits 145 | if (pinNumber < 0 || pinNumber > 7) return -1; 146 | 147 | if(pin.startsWith("D")) 148 | { 149 | return -3; 150 | } 151 | else if (pin.startsWith("A")) 152 | { 153 | return analogRead(pinNumber+10); 154 | } 155 | #if Wiring_Cellular 156 | else if (pin.startsWith("B")) 157 | { 158 | if (pinNumber < 2 || pinNumber > 5) return -3; 159 | return analogRead(pinNumber+24); 160 | } 161 | #endif 162 | return -2; 163 | } 164 | 165 | /******************************************************************************* 166 | * Function Name : tinkerAnalogWrite 167 | * Description : Writes an analog value (PWM) to the specified pin 168 | * Input : Pin and Value (0 to 255) 169 | * Output : None. 170 | * Return : 1 on success and a negative number on failure 171 | *******************************************************************************/ 172 | int tinkerAnalogWrite(String command) 173 | { 174 | String value = command.substring(3); 175 | 176 | if(command.substring(0,2) == "TX") 177 | { 178 | pinMode(TX, OUTPUT); 179 | analogWrite(TX, value.toInt()); 180 | return 1; 181 | } 182 | else if(command.substring(0,2) == "RX") 183 | { 184 | pinMode(RX, OUTPUT); 185 | analogWrite(RX, value.toInt()); 186 | return 1; 187 | } 188 | 189 | //convert ascii to integer 190 | int pinNumber = command.charAt(1) - '0'; 191 | //Sanity check to see if the pin numbers are within limits 192 | 193 | if (pinNumber < 0 || pinNumber > 7) return -1; 194 | 195 | if(command.startsWith("D")) 196 | { 197 | pinMode(pinNumber, OUTPUT); 198 | analogWrite(pinNumber, value.toInt()); 199 | return 1; 200 | } 201 | else if(command.startsWith("A")) 202 | { 203 | pinMode(pinNumber+10, OUTPUT); 204 | analogWrite(pinNumber+10, value.toInt()); 205 | return 1; 206 | } 207 | else if(command.substring(0,2) == "TX") 208 | { 209 | pinMode(TX, OUTPUT); 210 | analogWrite(TX, value.toInt()); 211 | return 1; 212 | } 213 | else if(command.substring(0,2) == "RX") 214 | { 215 | pinMode(RX, OUTPUT); 216 | analogWrite(RX, value.toInt()); 217 | return 1; 218 | } 219 | #if Wiring_Cellular 220 | else if (command.startsWith("B")) 221 | { 222 | if (pinNumber > 3) return -3; 223 | pinMode(pinNumber+24, OUTPUT); 224 | analogWrite(pinNumber+24, value.toInt()); 225 | return 1; 226 | } 227 | else if (command.startsWith("C")) 228 | { 229 | if (pinNumber < 4 || pinNumber > 5) return -4; 230 | pinMode(pinNumber+30, OUTPUT); 231 | analogWrite(pinNumber+30, value.toInt()); 232 | return 1; 233 | } 234 | #endif 235 | else return -2; 236 | } 237 | -------------------------------------------------------------------------------- /tplink-router/README.md: -------------------------------------------------------------------------------- 1 | # Using a TP-LINK Mini Router 2 | 3 | I like the TP-LINK N150 TL-WR702N mini-router. It's been replaced by the newer N300, which should be similar. It's tiny, can be powered by USB, and is under US$30. 4 | 5 | This note discusses using it on a wireless network where you need to agree to terms of service in a web page before getting access to the network (captive portal), like commonly occurs in hotels. The Photon doesn't work directly with those types of networks, but the TP-LINK router often does and can act as an intermediary. 6 | 7 | You'll need to connect your laptop to the TP-LINK router. You can do this either using Ethernet or Wi-Fi: 8 | 9 | ## Connecting by Ethernet 10 | 11 | - Plug in the router power 12 | - Connect it by Ethernet to your laptop. 13 | - Go into your network settings. Disable Wi-Fi. Enable Ethernet if necessary. 14 | - Select manual configuration, IP Address 192.168.0.100, Subnet Mask 255.255.255.0, Router 192.168.0.254. 15 | - Go to the web page: http://192.168.0.254 16 | - Log in with the default username and password, "admin" for both. 17 | 18 | 19 | ## Connecting by Wi-Fi 20 | 21 | - Plug in the router power 22 | - Select the TP-LINK Wi-Fi SSID on your laptop. It's printed on a label on the router. 23 | - Enter the password. It's printed in microscopic print on a label on the router. 24 | - Go to the web page: http://tplinklogin.net 25 | - Log in with the default username and password, "admin" for both. 26 | 27 | ## Configure the router 28 | 29 | The easiest way is to use **Quick Setup**. You probably will want **Bridge** mode. 30 | 31 | ![Enable bridging](images/1-tplink.png) 32 | 33 | The top block is the new network information, the one that your Photon and laptop will eventually connect to. 34 | 35 | The bottom block is the network your are connecting to, the one that has access to the Internet, such as the hotel network. Use the **Survey** button to select the network to connect to. This will fill in the SSID and BSSID fields for you. 36 | 37 | The password field at the bottom is the password for the network you are connecting to, such as a hotel network. 38 | 39 | ![Enable bridging](images/2-tplink.png) 40 | 41 | In the last page you enter the security information for the Wi-Fi network that you created. The SSID is the top one in the previous page, and the password is here. 42 | 43 | ![Enable bridging](images/3-tplink.png) 44 | 45 | ## Accept any terms of service 46 | 47 | If your laptop is connected by Ethernet you can leave it connected that way, or you can switch to Wi-Fi now. 48 | 49 | You must select the new Wi-Fi network you just created on your laptop. 50 | 51 | If you need to agree to terms of service, go to any web page now and you'll be redirected and can accept the terms of service. Make sure it's OK for you to add a router to their network. 52 | 53 | Once that's done and you can access the Internet through the TP-LINK router from your laptop, you can set up your Photon. 54 | 55 | ## Set up Photon 56 | 57 | You can now use whatever technique you like to set up your Photon. I prefer to use the CLI command: 58 | 59 | ``` 60 | particle serial wifi 61 | ``` 62 | 63 | This command does not change your device claiming and only resets the Wi-Fi network SSID and password. 64 | 65 | Make sure your Photon is in listening mode (blinking blue) before issuing the command. Hold down SETUP until it blinks blue. 66 | 67 | And of course enter the information for the new SSID and password you just created. 68 | -------------------------------------------------------------------------------- /tplink-router/images/1-tplink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/tplink-router/images/1-tplink.png -------------------------------------------------------------------------------- /tplink-router/images/2-tplink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/tplink-router/images/2-tplink.png -------------------------------------------------------------------------------- /tplink-router/images/3-tplink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/tplink-router/images/3-tplink.png -------------------------------------------------------------------------------- /upgrading-system-firmware/images/build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/upgrading-system-firmware/images/build.png -------------------------------------------------------------------------------- /upgrading-system-firmware/images/dev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/upgrading-system-firmware/images/dev.png -------------------------------------------------------------------------------- /usbvsserialflash.md: -------------------------------------------------------------------------------- 1 | # USB vs. Serial flash 2 | 3 | The --serial flash can fail because your code runs at the same time as the update, and it’s easy to accidentally interfere with it. I prefer to use the --usb (DFU) flash mode: 4 | 5 | Hold down the RESET and MODE button, release RESET and continue to hold down MODE while the main status LED blinks magenta, until it blinks yellow and then release MODE. This is DFU mode. 6 | 7 | Then issue a command such as: 8 | 9 | ``` 10 | particle flash --usb firmware.bin 11 | ``` 12 | 13 | If you get an error that dfu-util is not found, then you'll need to install it. For Windows, the easiest way is to run the Particle CLI installer; a link is at the bottom of the [Particle CLI page] (https://particle.io/cli). That page also has instructions for Mac and Linux. 14 | 15 | Don't worry about this message; it's not really an error and will always occur: 16 | 17 | ``` 18 | dfu-util: Invalid DFU suffix signature 19 | dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! 20 | ``` 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /using-travis-ci-with-particle/README.md: -------------------------------------------------------------------------------- 1 | # Using Travis CI with Particle Libraries 2 | 3 | [Travis CI](https://travis-ci.org) (continuous integration) is a great tool for validating your Particle libraries after you've made changes and committed them to Github. 4 | 5 | You can automatically link your Github and Travis CI accounts so a build starts immediately after committing to master or a branch. 6 | 7 | ## Getting a Particle Access Token 8 | 9 | For security reasons, you may want to create a separate Particle account that you use only for compiling. It doesn't need to have any devices in it. 10 | 11 | You can just another email address if you have one, or if you use Google Mail, you can the a plus email. For example, if your Google email address is johnsmith@gmail.com, you can sign up for a Particle account at johnsmith+travis@gmail.com and you'll have two separate Particle accounts, but the email will still go to your regular gmail account. 12 | 13 | Create an access token using the [Particle CLI](https://docs.particle.io/reference/developer-tools/cli/#particle-token-create) command `particle token create`. 14 | 15 | 16 | ## Enabling Travis 17 | 18 | Create a [Travis CI](https://travis-ci.org) account if you don't have one already and connect it to your Github account. The [Getting started guide](https://docs.travis-ci.com/user/getting-started/) will help. 19 | 20 | In the settings for your repository, add an **Environment Variable**. 21 | 22 | The name of the variable must be `AUTH_TOKEN` and the value is what you copied from build. 23 | 24 | ![Environment](images/environment.png) 25 | 26 | Once you've pasted it in, it won't be displayed again, so it's relatively secure. Also make sure the Display value in build log is not enabled, which will makes sure it's not displayed in the public build log! 27 | 28 | 29 | ## Updating your project 30 | 31 | You'll need a `.travis.yml` file in the top level of your Github repository, typically where your library.properties file is: 32 | 33 | ``` 34 | language: node_js 35 | node_js: lts/carbon 36 | ``` 37 | 38 | You'll also need a `package.json` file. Change the name to match your project, but it doesn't really matter. It's only there so Travis knows what dependencies to load. 39 | 40 | ``` 41 | { 42 | "name": "DS2482-RK", 43 | "version": "0.0.1", 44 | "description": "Travis build script", 45 | "private": true, 46 | "scripts": { 47 | "test": "node node_modules/@rickkas7/particle-builder/particle-builder.js ." 48 | }, 49 | "author": "rickkas7@github.com", 50 | "contributors": [ 51 | ], 52 | "license": "Apache Version 2.0", 53 | "dependencies": { 54 | "@rickkas7/particle-builder": "^0.0.2" 55 | }, 56 | "engines": { 57 | "node": ">=4.3.2" 58 | } 59 | } 60 | ``` 61 | 62 | Finally, you'll need a build.yml file. This is for the particle-builder tool and describes which platforms, versions, and examples to build. 63 | 64 | Here's a simple build.yml: 65 | 66 | ``` 67 | - build: examples/1-simple-SpiffsParticleRK 68 | photon: [0.7.0] 69 | p1: [latest] 70 | ``` 71 | 72 | This builds the example 1 for the Photon (system firmware 0.7.0) and the p1 (latest release version). 73 | 74 | Or, a more complicated example: 75 | 76 | ``` 77 | - build: examples/1-simple-SpiffsParticleRK 78 | photon: [0.6.3, 0.7.0, 0.8.0-rc.8] 79 | p1: [latest] 80 | electron: [latest] 81 | - build: examples/2-self-test-SpiffsParticleRK 82 | photon: [latest] 83 | - build: examples/3-stop-sleep-SpiffsParticleRK 84 | photon: [latest] 85 | - build: examples/4-deep-sleep--SpiffsParticleRK 86 | photon: [latest] 87 | - build: examples/5-benchmark-SpiffsParticleRK 88 | photon: [latest] 89 | ``` 90 | 91 | Unlike the default in Travis, this does not default to creating an n x n matrix, as in most cases this just results in a very large number of unnecessary builds. For example, the differences between the Photon and P1 are minimal, so the test coverage of the P1 is reduced in the example above. 92 | 93 | When you look at the output from Travis, you'll see the build output for each one of the platforms and directories specified in the build.yml file, like this: 94 | 95 | ``` 96 | Compiling code for photon 97 | Targeting version: 0.6.3 98 | Including: 99 | examples/1-simple-SpiffsParticleRK/1-simple-SpiffsParticleRK.cpp 100 | library.properties 101 | src/SpiffsParticleRK.cpp 102 | src/SpiffsParticleRK.h 103 | src/spiffs.h 104 | src/spiffs_cache.c 105 | src/spiffs_check.c 106 | src/spiffs_config.h 107 | src/spiffs_gc.c 108 | src/spiffs_hydrogen.c 109 | src/spiffs_nucleus.c 110 | src/spiffs_nucleus.h 111 | attempting to compile firmware 112 | downloading binary from: /v1/binaries/5b3b8a6d3fa1d974ee07ab06 113 | saving to: firmware.bin 114 | Memory use: 115 | text data bss dec hex filename 116 | 39148 120 1836 41104 a090 /workspace/target/workspace.elf 117 | Compile succeeded. 118 | Saved firmware to: /home/travis/build/rickkas7/SpiffsParticleRK/firmware.bin 119 | compile exited with code 0 120 | ``` 121 | 122 | If an error occurs, the Travis log will show the error and the build will stop with a failed Travis build. 123 | 124 | You can see the three files (.travis.yml, package.json, build.yml) in an actual project [here](https://github.com/rickkas7/SpiffsParticleRK). 125 | 126 | You can see the Travis CI build output [here](https://travis-ci.org/rickkas7/SpiffsParticleRK). 127 | -------------------------------------------------------------------------------- /using-travis-ci-with-particle/images/environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/using-travis-ci-with-particle/images/environment.png -------------------------------------------------------------------------------- /using-travis-ci-with-particle/images/user_token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/using-travis-ci-with-particle/images/user_token.png -------------------------------------------------------------------------------- /wpa2-enterprise/README.md: -------------------------------------------------------------------------------- 1 | # WPA2 Enterprise Configuration 2 | 3 | Starting with Particle Device OS 0.7.0 you can use the Photon and P1 on a WPA2 Enterprise Wi-Fi network. This type of network is common in university and corporate networks. If you see a reference to RADIUS, 802.1(x), need to enter both a username and password, or have a certificate or key file, you probably have a WPA2 Enterprise network. 4 | 5 | Most home networks use WPA2 Personal and have a simpler setup that only requires a SSID (network name) and a password and do not require these steps. 6 | 7 | This is also different than situations where you enter a password (sometimes a username or email address as well) into a web page to get onto the network. That's referred to as a captive portal and is common in hotel and other public Wi-Fi networks. Captive portals are not supported. 8 | 9 | ## Install the Particle CLI 10 | 11 | You should install the Particle Command Line Interface using the [Particle CLI Installer](https://docs.particle.io/guide/tools-and-features/cli/photon/) for Windows, Mac, or Linux if you have not already done so. 12 | 13 | It's the easiest way to upgrade the Particle Device OS on your Photon and set up WPA2 Enterprise. 14 | 15 | It is not currently possible to do a WPA2 Enterprise setup using the Particle mobile apps or a web-based setup. 16 | 17 | ## Upgrade your Photon 18 | 19 | Photons and P1s ship with an earlier version of the Particle Device OS that does not support WPA2 Enterprise, so you will need to upgrade it first over USB. 20 | 21 | Put the Photon in [DFU mode](https://docs.particle.io/guide/getting-started/modes/photon/#dfu-mode-device-firmware-upgrade-) (blinking yellow) by holding down RESET and SETUP, releasing RESET and continuing to hold down SETUP while the main LED blinks magenta until it blinks yellow, then release. 22 | 23 | Then from a Command Prompt or Terminal window, enter the command: 24 | 25 | ``` 26 | particle update 27 | ``` 28 | 29 | ## Configure your Photon 30 | 31 | Connect the Photon to your computer using USB and put the device in [listening mode] (https://docs.particle.io/guide/getting-started/modes/electron/#listening-mode) (blinking dark blue) by holding down the SETUP (or MODE) button until the main status LED blinks dark blue, about 3 seconds, if not already blinking blue. 32 | 33 | In a Command Prompt or Terminal window, enter the command: 34 | 35 | ``` 36 | particle serial identify 37 | ``` 38 | 39 | This will print out the Device ID of your Photon, which you may need later. 40 | 41 | Then enter the command: 42 | 43 | ``` 44 | particle serial wifi 45 | ``` 46 | 47 | Select the SSID of the network you want to log into. You can either scan for it or manually enter it. You can either scan for the security type and cipher or manually select it as well. 48 | 49 | Then you'll need to select the EAP Type. This option only appears if you are using a WPA Enterprise or WPA2 Enterprise network. 50 | 51 | ``` 52 | EAP Type 0=PEAP/MSCHAPv2, 1=EAP-TLS: 53 | ``` 54 | 55 | ### PEAP/MSCHAPv2 LOGIN / PASSWORD based setup 56 | 57 | If your enterprise network uses PEAP/MSCHAPv2 and does not provide any certificates or keys, only a username and password, follow these instructions: 58 | 59 | ``` 60 | EAP Type 0=PEAP/MSCHAPv2, 1=EAP-TLS: 0 61 | Username: YOUR_USERNAME 62 | Password: YOUR_PASSWORD 63 | Outer identity (optional): 64 | Root CA in PEM format (optional): 65 | ``` 66 | 67 | On some networks, such as the default setting in Windows NPS, the Outer identity is required to be the same as your Username. If you are unable to connect with the Outer identity blank, try setting it to your Username. 68 | 69 | This is the easiest setup method to gain a connection, however it is not secure. Whenever possible use certificates to ensure maximum security. 70 | 71 | ### PEAP/MSCHAPv2 LOGIN / PASSWORD with Root CA 72 | 73 | If your enterprise network uses PEAP/MSCHAPv2 and has a Root CA (certificate authority) certificate, follow these instructions: 74 | 75 | ``` 76 | EAP Type 0=PEAP/MSCHAPv2, 1=EAP-TLS: 0 77 | Username: YOUR_USERNAME 78 | Password: YOUR_PASSWORD 79 | Outer identity (optional): 80 | Root CA in PEM format (optional): 81 | -----BEGIN CERTIFICATE----- 82 | MIIFlDCCA3ygAwIBAgIJAI01a4ML65mlMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNV 83 | ... 84 | -----END CERTIFICATE----- 85 | ``` 86 | 87 | This is the setting you'd typically used for [eduroam](https://www.eduroam.org/). 88 | 89 | 90 | ### EAP-TLS with Client Certificate, Client Key and Root CA 91 | 92 | ``` 93 | EAP Type 0=PEAP/MSCHAPv2, 1=EAP-TLS: 1 94 | Client certificate in PEM format: 95 | -----BEGIN CERTIFICATE----- 96 | MIIE3DCCAsSgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwVzELMAkGA1UEBhMCVVMx 97 | ... 98 | -----END CERTIFICATE----- 99 | 100 | Private key in PEM format: 101 | -----BEGIN RSA PRIVATE KEY----- 102 | MIIEpAIBAAKCAQEAy42H10w6nntp+Ti7Ts/czel8Gw4mz8Mh3N0R/sapRNLyznom 103 | ... 104 | -----END RSA PRIVATE KEY----- 105 | 106 | Outer identity (optional): 107 | Root CA in PEM format (optional): 108 | -----BEGIN CERTIFICATE----- 109 | MIIFlDCCA3ygAwIBAgIJAI01a4ML65mlMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNV 110 | ... 111 | -----END CERTIFICATE----- 112 | ``` 113 | 114 | ### Output 115 | 116 | After entering the keys in one of the above methods, the following should be displayed: 117 | 118 | ``` 119 | Thanks! Wait while I save those credentials... 120 | 121 | Awesome. Now we'll connect! 122 | 123 | If you see a pulsing cyan light, your device 124 | has connected to the Cloud and is ready to go! 125 | 126 | If your LED flashes red or you encounter any other problems, 127 | visit https://www.particle.io/support to debug. 128 | 129 | Particle <3 you! 130 | ``` 131 | 132 | ## Claim your device 133 | 134 | If this is the first time you've used your Photon, you will need to claim it. If you've already set up your Photon using a non-enterprise network, you should skip this step. 135 | 136 | The normal sequence on the status LED is: white, blinking green, blinking cyan (light blue), fast blinking cyan, and finally breathing cyan. 137 | 138 | You can only claim your device when it's breathing cyan. If it's not breathing cyan, troubleshoot that first before trying to claim. 139 | 140 | In a Command Prompt or Terminal window enter the command: 141 | 142 | ``` 143 | particle device add YOUR_DEVICE_ID 144 | ``` 145 | 146 | Replace `YOUR_DEVICE_ID` with the Device ID you got earlier from `particle serial identify`. 147 | 148 | The device ID uniquely identifies your Particle device (Photon, Electron, P1, Core, etc.) to the Particle cloud. It consists of 24 hexadecimal characters, and looks like this: 1e0032123447343149111039. 149 | 150 | For example: 151 | 152 | ``` 153 | particle device add 1e0032123447343149111039 154 | ``` 155 | 156 | 157 | ## Troubleshooting 158 | 159 | To troubleshoot the connection process, download the TinkerDebug070.bin file. 160 | 161 | Put the Photon in [DFU mode](https://docs.particle.io/guide/getting-started/modes/photon/#dfu-mode-device-firmware-upgrade-) (blinking yellow) by holding down RESET and SETUP, releasing RESET and continuing to hold down SETUP while the main LED blinks magenta until it blinks yellow, then release. 162 | 163 | Then from a Command Prompt or Terminal window, enter the command: 164 | 165 | ``` 166 | cd Downloads 167 | particle flash --usb TinkerDebug070.bin 168 | ``` 169 | 170 | The monitor the status using a terminal program, as above, or: 171 | 172 | ``` 173 | particle serial monitor 174 | ``` 175 | 176 | Note that particle serial monitor only monitors the serial port, and you can use it to configure WPA2 Enterprise as you cannot type into it to send commands to the Photon. 177 | 178 | You can also find helpful advice in [this community forum post](https://community.particle.io/t/setting-up-photon-p1-on-wpa-enterprise-0-7-0/34167). 179 | 180 | Some common errors include: 181 | 182 | - 1006 NOT\_AUTHENTICATED 183 | - 1007 NOT\_KEYED 184 | - 1024 NETWORK\_NOT\_FOUND 185 | - 1025 INVALID\_JOIN\_STATUS 186 | 187 | The [full list of errors is here](https://github.com/particle-iot/firmware/blob/develop/hal/src/photon/wiced/WWD/include/wwd_constants.h#L489). 188 | -------------------------------------------------------------------------------- /wpa2-enterprise/TinkerDebug.cpp: -------------------------------------------------------------------------------- 1 | #include "Particle.h" 2 | 3 | SerialLogHandler logHandler(LOG_LEVEL_ALL); 4 | 5 | /* Function prototypes -------------------------------------------------------*/ 6 | int tinkerDigitalRead(String pin); 7 | int tinkerDigitalWrite(String command); 8 | int tinkerAnalogRead(String pin); 9 | int tinkerAnalogWrite(String command); 10 | 11 | SYSTEM_MODE(AUTOMATIC); 12 | 13 | /* This function is called once at start up ----------------------------------*/ 14 | void setup() 15 | { 16 | //Setup the Tinker application here 17 | 18 | //Register all the Tinker functions 19 | Particle.function("digitalread", tinkerDigitalRead); 20 | Particle.function("digitalwrite", tinkerDigitalWrite); 21 | 22 | Particle.function("analogread", tinkerAnalogRead); 23 | Particle.function("analogwrite", tinkerAnalogWrite); 24 | } 25 | 26 | /* This function loops forever --------------------------------------------*/ 27 | void loop() 28 | { 29 | //This will run in a loop 30 | } 31 | 32 | /******************************************************************************* 33 | * Function Name : tinkerDigitalRead 34 | * Description : Reads the digital value of a given pin 35 | * Input : Pin 36 | * Output : None. 37 | * Return : Value of the pin (0 or 1) in INT type 38 | Returns a negative number on failure 39 | *******************************************************************************/ 40 | int tinkerDigitalRead(String pin) 41 | { 42 | //convert ascii to integer 43 | int pinNumber = pin.charAt(1) - '0'; 44 | //Sanity check to see if the pin numbers are within limits 45 | if (pinNumber < 0 || pinNumber > 7) return -1; 46 | 47 | if(pin.startsWith("D")) 48 | { 49 | pinMode(pinNumber, INPUT_PULLDOWN); 50 | return digitalRead(pinNumber); 51 | } 52 | else if (pin.startsWith("A")) 53 | { 54 | pinMode(pinNumber+10, INPUT_PULLDOWN); 55 | return digitalRead(pinNumber+10); 56 | } 57 | #if Wiring_Cellular 58 | else if (pin.startsWith("B")) 59 | { 60 | if (pinNumber > 5) return -3; 61 | pinMode(pinNumber+24, INPUT_PULLDOWN); 62 | return digitalRead(pinNumber+24); 63 | } 64 | else if (pin.startsWith("C")) 65 | { 66 | if (pinNumber > 5) return -4; 67 | pinMode(pinNumber+30, INPUT_PULLDOWN); 68 | return digitalRead(pinNumber+30); 69 | } 70 | #endif 71 | return -2; 72 | } 73 | 74 | /******************************************************************************* 75 | * Function Name : tinkerDigitalWrite 76 | * Description : Sets the specified pin HIGH or LOW 77 | * Input : Pin and value 78 | * Output : None. 79 | * Return : 1 on success and a negative number on failure 80 | *******************************************************************************/ 81 | int tinkerDigitalWrite(String command) 82 | { 83 | bool value = 0; 84 | //convert ascii to integer 85 | int pinNumber = command.charAt(1) - '0'; 86 | //Sanity check to see if the pin numbers are within limits 87 | if (pinNumber < 0 || pinNumber > 7) return -1; 88 | 89 | if(command.substring(3,7) == "HIGH") value = 1; 90 | else if(command.substring(3,6) == "LOW") value = 0; 91 | else return -2; 92 | 93 | if(command.startsWith("D")) 94 | { 95 | pinMode(pinNumber, OUTPUT); 96 | digitalWrite(pinNumber, value); 97 | return 1; 98 | } 99 | else if(command.startsWith("A")) 100 | { 101 | pinMode(pinNumber+10, OUTPUT); 102 | digitalWrite(pinNumber+10, value); 103 | return 1; 104 | } 105 | #if Wiring_Cellular 106 | else if(command.startsWith("B")) 107 | { 108 | if (pinNumber > 5) return -4; 109 | pinMode(pinNumber+24, OUTPUT); 110 | digitalWrite(pinNumber+24, value); 111 | return 1; 112 | } 113 | else if(command.startsWith("C")) 114 | { 115 | if (pinNumber > 5) return -5; 116 | pinMode(pinNumber+30, OUTPUT); 117 | digitalWrite(pinNumber+30, value); 118 | return 1; 119 | } 120 | #endif 121 | else return -3; 122 | } 123 | 124 | /******************************************************************************* 125 | * Function Name : tinkerAnalogRead 126 | * Description : Reads the analog value of a pin 127 | * Input : Pin 128 | * Output : None. 129 | * Return : Returns the analog value in INT type (0 to 4095) 130 | Returns a negative number on failure 131 | *******************************************************************************/ 132 | int tinkerAnalogRead(String pin) 133 | { 134 | //convert ascii to integer 135 | int pinNumber = pin.charAt(1) - '0'; 136 | //Sanity check to see if the pin numbers are within limits 137 | if (pinNumber < 0 || pinNumber > 7) return -1; 138 | 139 | if(pin.startsWith("D")) 140 | { 141 | return -3; 142 | } 143 | else if (pin.startsWith("A")) 144 | { 145 | return analogRead(pinNumber+10); 146 | } 147 | #if Wiring_Cellular 148 | else if (pin.startsWith("B")) 149 | { 150 | if (pinNumber < 2 || pinNumber > 5) return -3; 151 | return analogRead(pinNumber+24); 152 | } 153 | #endif 154 | return -2; 155 | } 156 | 157 | /******************************************************************************* 158 | * Function Name : tinkerAnalogWrite 159 | * Description : Writes an analog value (PWM) to the specified pin 160 | * Input : Pin and Value (0 to 255) 161 | * Output : None. 162 | * Return : 1 on success and a negative number on failure 163 | *******************************************************************************/ 164 | int tinkerAnalogWrite(String command) 165 | { 166 | String value = command.substring(3); 167 | 168 | if(command.substring(0,2) == "TX") 169 | { 170 | pinMode(TX, OUTPUT); 171 | analogWrite(TX, value.toInt()); 172 | return 1; 173 | } 174 | else if(command.substring(0,2) == "RX") 175 | { 176 | pinMode(RX, OUTPUT); 177 | analogWrite(RX, value.toInt()); 178 | return 1; 179 | } 180 | 181 | //convert ascii to integer 182 | int pinNumber = command.charAt(1) - '0'; 183 | //Sanity check to see if the pin numbers are within limits 184 | 185 | if (pinNumber < 0 || pinNumber > 7) return -1; 186 | 187 | if(command.startsWith("D")) 188 | { 189 | pinMode(pinNumber, OUTPUT); 190 | analogWrite(pinNumber, value.toInt()); 191 | return 1; 192 | } 193 | else if(command.startsWith("A")) 194 | { 195 | pinMode(pinNumber+10, OUTPUT); 196 | analogWrite(pinNumber+10, value.toInt()); 197 | return 1; 198 | } 199 | else if(command.substring(0,2) == "TX") 200 | { 201 | pinMode(TX, OUTPUT); 202 | analogWrite(TX, value.toInt()); 203 | return 1; 204 | } 205 | else if(command.substring(0,2) == "RX") 206 | { 207 | pinMode(RX, OUTPUT); 208 | analogWrite(RX, value.toInt()); 209 | return 1; 210 | } 211 | #if Wiring_Cellular 212 | else if (command.startsWith("B")) 213 | { 214 | if (pinNumber > 3) return -3; 215 | pinMode(pinNumber+24, OUTPUT); 216 | analogWrite(pinNumber+24, value.toInt()); 217 | return 1; 218 | } 219 | else if (command.startsWith("C")) 220 | { 221 | if (pinNumber < 4 || pinNumber > 5) return -4; 222 | pinMode(pinNumber+30, OUTPUT); 223 | analogWrite(pinNumber+30, value.toInt()); 224 | return 1; 225 | } 226 | #endif 227 | else return -2; 228 | } 229 | -------------------------------------------------------------------------------- /wpa2-enterprise/TinkerDebug070.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/particle_notes/60ba2b550b014e13ae3adb7a11104ca3515edeaf/wpa2-enterprise/TinkerDebug070.bin --------------------------------------------------------------------------------