Has anyone tried using openThread with Particle.io products? They just shipped last week. Lots of potential here for interesting projects.
--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/155cebdc-862c-42a0-81e0-9a89d97cac16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/87c34a19-ef03-43c5-af72-c654a2751100%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/38c735e9-974c-4e0e-9575-c086c08a2b23%40googlegroups.com.
#include "Particle.h"
// Easiest RSSI test program
// By Jeremy Ellis
#include "ot_api.h"
extern "C" {
int8_t otPlatRadioGetRssi(otInstance *aInstance);
};
void setup() {
}
void loop() {
int8_t rssi = otPlatRadioGetRssi(0);
//snprintf(buf, sizeof(buf), “>%d <%d”, (int)rssi, lastRssi);
Particle.publish("RSSI ", "#" + String(rssi), 60, PRIVATE); //shows printing an integer variable
Particle.publish("----------------","-------------", 60, PRIVATE); // just to show a space between samples
delay(10000); // wait about 10 seconds
}
$ wpanctl leave
$ wpanctl join -T r -p <panid> -c <channel> -k <masterkey> -n <networkname>
2. Add an End Device,3. Add a REED (Router Eligible End Device)
Many of the other abilities are pre-compiled into the Particle Devices.Even a list of commands to look into would be appreciated.1. otPlatRadioGetRssi(otInstance *aInstance)2345678
--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/82b9c76f-74c0-41b7-8135-3b0c3138f199%40googlegroups.com.

And my output after doing some print statements (Particle.publish(String(),String(),60,Private);) looks like

Fairly sure the NetworkName is a simple string not the mess I am getting, and the Master Key should be much longer (Is it compressed?). Any suggestions?
P.S. Why do I pass (0) to each method?
#include "Particle.h"
#include "ot_api.h"extern "C" { int8_t otLinkGetChannel(otInstance *aInstance); uint16_t otLinkGetPanId(otInstance *aInstance); // type otPanId uint8_t otThreadGetMasterKey(otInstance *aInstance); char *otThreadGetNetworkName(otInstance *aInstance); };
void loop() { int8_t myChannel = otLinkGetChannel(0); uint16_t myPanID = otLinkGetPanId(0); // otPanId char myPanIDBuff[255]; snprintf(myPanIDBuff, sizeof(myPanIDBuff), "0x%X", myPanID); // put hex into myPanIDBuff uint8_t myMasterKey = otThreadGetMasterKey(0); char *myNetworkName = otThreadGetNetworkName(0); char myNetworkNameBuff[255]; snprintf(myNetworkNameBuff, sizeof(myNetworkNameBuff), "%s", myNetworkName); // network name as a string
Particle.publish("----------------","-------------", 60, PRIVATE); // just to show a space between samples delay(2000); Particle.publish("Particle Thread ","Connection Information", 60, PRIVATE); // just to show a space between samples delay(2000); Particle.publish("My Channel: ", String(myChannel), 60, PRIVATE); //shows printing an integer variable delay(2000); Particle.publish("Argon Pan ID: ", String(myPanIDBuff), 60, PRIVATE); //shows printing an integer variable delay(2000); Particle.publish("My Master Key: ", String(myMasterKey), 60, PRIVATE); //shows printing an integer variable delay(2000); Particle.publish("My Network Name: ", String(myNetworkNameBuff), 60, PRIVATE); //shows printing an integer variable delay(2000); Particle.publish("----------------","-------------", 60, PRIVATE); // just to show a space between samples delay(2000); Particle.publish("Generates the same info","every 60 seconds", 60, PRIVATE); // just to show a space between samples delay(60000); // wait 60 seconds before re-print}--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/077207b1-fe16-4e17-9224-d76f7e06c99f%40googlegroups.com.
sudo /usr/local/bin/wpanctl
help
scan
| Joinable | NetworkName | PAN ID | Ch | XPanID | HWAddr | RSSI
---+----------+--------------------+--------+----+------------------+------------------+------
1 | NO | "b_group" | 0x3844 | 11 | C93A555AC477FF4A | 123444F7B9F8D07B | -64
setprop NetworkKey --data f73f8a29d093eb1c4d444eb31649a483
join 1
or
join -T r -p 0x3844 -c 11 -x C93A555AC477FF4A b_group
status
getprop -a
--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/8891d824-b5e5-41b4-819f-0b66be18c8cb%40googlegroups.com.
At a minimum, OTBR needs to know the Channel, PAN ID, Thread Master Key, and Network Name to join a network.
To retrieve the Particle device Thread Network configuration, you can use:
otDatasetGetActive() to retrieve all the parameters in one structure, or
otLinkGetChannel(), otLinkGetPanId(), otThreadGetMasterKey(), otThreadGetNetworkName() to retrieve them individually.
networkName.SetNetworkName(netif.GetMac().GetNetworkName());netif.GetKeyManager().SetMasterKey(key->GetNetworkMasterKey());#define OT_MASTER_KEY_SIZE 16
#include "ot_api.h"
#include "openthread/dataset.h"
extern "C" {
int8_t otLinkGetChannel(otInstance *aInstance);
uint16_t otLinkGetPanId(otInstance *aInstance); // type otPanId
otMasterKey *otThreadGetMasterKey(otInstance *aInstance);
char *otThreadGetNetworkName(otInstance *aInstance);
};
void loop() {
otInstance* ot = ot_get_instance();
int8_t myChannel = otLinkGetChannel(ot);
uint16_t myPanID = otLinkGetPanId(ot); // otPanId
// etc, etc ...
}
--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/d19ef984-7593-4348-b98c-1380d6d825ee%40googlegroups.com.
/* Set master key to 1234C0DE1AB51234C0DE1AB51234C0DE */
uint8_t key[OT_MASTER_KEY_SIZE] = {0x12, 0x34, 0xC0, 0xDE, 0x1A, 0xB5, 0x12, 0x34, 0xC0, 0xDE, 0x1A, 0xB5};To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/e1c1249c-c6e7-47c7-87f8-486e36ada611%40googlegroups.com.
In main.c, add these function calls to the main() function after the otSysButtonInit call. This function configures the Thread network dataset.
/* Start the Thread network interface (CLI cmd > ifconfig up) */ otIp6SetEnabled(instance, true); /* Start the Thread stack (CLI cmd > thread start) */ otThreadSetEnabled(instance, true);
#if OPENTHREAD_FTD
ACTION: Add calls to initialize the GPIO LEDs and button
In main.c, add these function calls to the main() function after the otSetStateChangedCallback call. These functions initialize the GPIO and GPIOTE pins and set a button handler to handle button push events.
/* init GPIO LEDs and button */ otSysLedInit(); otSysButtonInit(handleButtonInterrupt);
--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/f65787aa-9c58-402b-b555-aa8af9bd675d%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to openthre...@googlegroups.com.
/* * Particle Mesh Devices Connection with Openthread * By Jeremy Ellis * Twitter @rocksetta * MIT license * D0 to 3V3 send Mesh.publish to all devices flash D7 * D3 to 3V3 send Particle.publish to the console with generic information * D6 to 3V3 disconnect wifi. Presently only works after wifi connected at startup. * Warning, will need Argon binaries to get Particle back to normal * v1.4.1-rc.1 found at the below link * https://github.com/particle-iot/device-os/releases/download/v1.4.1-rc.1/particle_...@1.4.1-rc.1.zip * Latest OS Device information found at the bottom of this blog * https://community.particle.io/t/particle-device-os-updates-thread/14378/97 * files are in the \1.4.1-rc.1\argon\release\ * particle flash --usb argon-sys...@1.4.1-rc.1.bin * reminder if you have to rer-install the boatloader you must flash in serial mode first then dfu for the system file * particle flash --serial argon-bo...@1.4.1-rc.1.bin * To run the below code you must install po-util with the following * Might want to pre install git, node, npm and particle-cli * sudo apt install curl * bash <(curl -sL get.po-util.com) * To check po-util version type * po * To start a po-util project * po init argon myArgonProject * cd myArgonProject * po config mesh-develop * po setup-mesh * MODULAR=n po argon build * particle login * particle list * particle flash --usb myArgonProject-argon.bin * Good idea between builds to clean * po argon clean */ #include "Particle.h" // uncomment the next line to improve stability SYSTEM_THREAD(ENABLED); // causes a small delay for Mesh.publish() SYSTEM_MODE(SEMI_AUTOMATIC); // so wifi not needed //Next line allows you to use the Particle Featherwing plug and play //STARTUP(System.enableFeature(FEATURE_ETHERNET_DETECTION)); #define OT_MASTER_KEY_SIZE 16 #include <assert.h> #include "ot_api.h" #include "openthread/dataset.h" // Following line might be needed //#include <openthread/thread_ftd.h> #include <string.h> extern "C" { int8_t otLinkGetChannel(otInstance *aInstance); uint16_t otLinkGetPanId(otInstance *aInstance); otMasterKey *otThreadGetMasterKey(otInstance *aInstance); char *otThreadGetNetworkName(otInstance *aInstance); otOperationalDataset aDataset; void myHandler(const char *event, const char *data); }; /////////////////////////// important globals here /////////////////////////////// int myCode = 5; // number of flashes bool myXenonAntennaAttached = false; bool myArgonBothAntennaAttached = false; bool myPublishToConsole = true; // set true for Argon for debugging int myCount = 0; bool myButtonReady = true; /////////////////////////////// end globals //////////////////////////// void setup() { // runs once pinMode(D0, INPUT_PULLDOWN); // set pin D0 as LOW input send Mesh.publish on HIGH pinMode(D3, INPUT_PULLDOWN); // set pin D3 as LOW input send particle.publish on HIGH pinMode(D6, INPUT_PULLDOWN); // set pin D6 as LOW input wifi off on HIGH pinMode(D7, OUTPUT); // our trusty D7 LED if (digitalRead(D6) == 0){ // If D6 HIGH connect wifi Particle.connect(); } Mesh.subscribe("mySendToAll", myHandler); if (myXenonAntennaAttached){ #if (PLATFORM_ID == PLATFORM_XENON) digitalWrite(ANTSW1, 0); digitalWrite(ANTSW2, 1); #endif } if (myArgonBothAntennaAttached){ #if (PLATFORM_ID == PLATFORM_ARGON) digitalWrite(ANTSW1, 1); digitalWrite(ANTSW2, 0); #endif } // Set Mesh Dataset memset(&aDataset, 0, sizeof(otOperationalDataset)); /* Set Network Name to OTCodelab */ static char aNetworkName[] = "OTCodelab"; size_t length = strlen(aNetworkName); assert(length <= OT_NETWORK_NAME_MAX_SIZE); memcpy(aDataset.mNetworkName.m8, aNetworkName, length); aDataset.mComponents.mIsNetworkNamePresent = true; /* * Fields that can be configured in otOperationDataset to override defaults: * Network Name, Mesh Local Prefix, Extended PAN ID, PAN ID, Delay Timer, * Channel, Channel Mask Page 0, Network Master Key, PSKc, Security Policy */ aDataset.mActiveTimestamp = 1; aDataset.mComponents.mIsActiveTimestampPresent = true; /* Set Channel to 15 */ aDataset.mChannel = 15; aDataset.mComponents.mIsChannelPresent = true; /* Set Pan ID to 2222 */ aDataset.mPanId = (otPanId)0x2222; aDataset.mComponents.mIsPanIdPresent = true; /* Set Extended Pan ID to C0DE1AB5C0DE1AB5 */ uint8_t extPanId[OT_EXT_PAN_ID_SIZE] = {0xC0, 0xDE, 0x1A, 0xB5, 0xC0, 0xDE, 0x1A, 0xB5}; memcpy(aDataset.mExtendedPanId.m8, extPanId, sizeof(aDataset.mExtendedPanId)); aDataset.mComponents.mIsExtendedPanIdPresent = true; /* Set master key to 1234C0DE1AB51234C0DE1AB51234C0DE */ uint8_t key[OT_MASTER_KEY_SIZE] = {0x12, 0x34, 0xC0, 0xDE, 0x1A, 0xB5, 0x12, 0x34, 0xC0, 0xDE, 0x1A, 0xB5}; memcpy(aDataset.mMasterKey.m8, key, sizeof(aDataset.mMasterKey)); aDataset.mComponents.mIsMasterKeyPresent = true; } void loop() { // runs continuously myCount +=1; if (myButtonReady && digitalRead(D0) == 1){ myCount = 0; digitalWrite(D7, 1); myButtonReady = false; Particle.publish("Sending Mesh Multicast", "...", 60, PRIVATE); Mesh.publish("mySendToAll", String(myCode)); delay(1000); digitalWrite(D7, 0); } if (myButtonReady && digitalRead(D3) == 1){ // If D3 is HIGH print info to console // Must have an otInstance otInstance* ot = ot_get_instance(); otDatasetSetActive(ot, &aDataset); char *myNetworkName = otThreadGetNetworkName(ot); char myNetworkNameBuff[255]; snprintf(myNetworkNameBuff, sizeof(myNetworkNameBuff), "%s", myNetworkName); // network name as a string Particle.publish("Successful","Startup", 60, PRIVATE); delay(2000); Particle.publish("My Network Name: ", String(myNetworkNameBuff), 60, PRIVATE); delay(2000); // Mesh.localIP().toString().c_str()); Particle.publish("My local ip: ", String(Mesh.localIP()), 60, PRIVATE); //shows local Mesh IPv4 address delay(2000); } if (digitalRead(D6) == 0){ // If D6 is HIGH Particle.connect(); // I am a Photon (has Wifi) } else { Particle.disconnect(); // I am an Arduino (no Wifi) } if (myCount >= 1000){ if (! myButtonReady){ // Particle.publish("Next D7 can happen in ", "about 10 seconds", 60, PRIVATE); } myButtonReady = true; } delay(10); // becomes about 5 seconds with the 1000 count } // Event listener for "mySendToAll" event from Mesh Devices void myHandler(const char *event, const char *data) { String parse = data; //Cast char*data to String class int myNumber = parse.toInt(); if (myPublishToConsole){ // mainly for Argon gateway unless debugging Particle.publish("Flashing D7 this many times:", parse, 60, PRIVATE); } for (int myLoop = 0; myLoop < myNumber; myLoop++){ digitalWrite(D7, HIGH); delay(200); // very quick flash digitalWrite(D7, LOW); delay(200); } delay(500); // to tell if 2 devices signal at similar times }