Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

Necessary Hardware

  • Microcontroller/development board of your choice
    • With necessary programmer
  • SmartMesh IP Mote (DC9003A-B)
    • With 6 female-female jumper cables
  • SmartMesh IP Manager (DC2274A-A)
  • SmartMesh Interface Board (DC9006A)
    • With USB-A to USB-micro cable
  • Computer (should support Python and Java)

Necessary Software

Downloading Libraries
Anchor
sec_download
sec_download

There are two ways to download the QuickStart Library:

a) Clone The Source Code

Clone the repository

...

Initialize and update the neccessary C Library submodule:

 

...

(...)/QuickStart_Library $ git submodule init
(...)/QuickStart_Library $ git submodule update

with git (or a git GUI client):

$ git clone https://github.com/dustcloud/QSL-for-sm_clib.git

Enter the repository:

$ cd QSL-for-sm_clib

Initialize and  update the necessary C Library submodule:

$ git submodule init
$ git submodule update


You can also checkout the latest release with subversion:

$ svn checkout https://github.com/dustcloud/QSL-for-sm_clib.git

but then you will also have to checkout the latest release of the C Library, since SVN does not support git submodules:

$ svn checkout https://github.com/dustcloud/sm_clib.git

b) Download Zip/Tar

  1. Go to the QSL release page and and download the  the latest zip/tarTODO: Add link when public repo created.
  2. Go to the C Library release page and download the  the latest zip/tar: TODO: Can possibly be added as attachment to QSL release. If not: Make a note about why it needs . The C Library is automatically generated from the SmartMesh IP stack library source, and so it may change with each stack release and needs to be downloaded separately.
  3. Unzip the files using your favourite compression tool.

Directory Structure

The QSL repository contains the following directories:

  • sm_qsl/ contains the QuickStart Library as a collection of headers (.h) and source code files (.c).
  • sm_clib/ is a submodule that contains the underlying C Library, with sample applications for its direct use.
    • sm_clib/ is the C Library itself as a collection of headers (.h) and source code files (.c).
      • ports/ contains an example of the necessary C Library ports.
    • examples/ contains sample applications which use the C Library directly.
  • examples/ contains sample applications utilizing the QSL
    • rpi/SimplePublish/ contains an example that connects and starts publishing random data, where the necessary porting functions have been implemented for the Raspberry Pi.
    • samc21_xplained_pro/SimplePublish/ contains the same example for the SAM C21 Xplained Pro evaluation board.
    • nucleo-l053r8/SimplePublish/ contains the same example for the NUCLEO-L053R8 development board.
       

...

Note

If you chose the zip download or subversion checkout, the sm_clib/ directory from the separate unzipped folder

...

 

/svn checkout should be copied into the QSL repository, as some example code will expect the above structure.


The SmartMesh QuickStart Library, and C Library it depends on, are both designed so you can drop their directories into your application without modification, i.e. these two folders from the structure above:

...

In addition to the files in these folders, you need to implement a handful of functions, as discussed in the next section.

Port to Your Hardware

The QSL and the underlying C Library are written to be used as-is in any C-based platform; however, you have to implement a handful of functions to adapt them to a specific platform. These functions are implemented in the example code provided for certain platforms (presented in later chapters), so you can skip the details of this section for now if you plan on using these (or simply wish to have a look at the examples first).

 The necessary functions are declared in following header files:

  • dn_uart.h: These functions allow the SmartMesh C Library to send bytes over the serial port, and receive bytes from the serial port. A "flush" function is provided in case the serial (UART) driver of the user platform is frame-oriented rather than byte-oriented.
  • dn_lock.h: These functions allow the SmartMesh C Library to operate in a multi-threaded environment. If this is the case in the user system, the implementation of these functions would typically consist of pending/posting a mutual exclusion semaphore (mutex); if not, simply use stub functions (i.e. "empty functions").
  • dn_endianness.h: These functions are used to match multi-byte API fields (which are big-endian) to the endianness of the platform.
  • dn_time.h: These functions allows the QSL to perform timing and schedule tasks.
  • dn_watchdog.h: These functions allow the QSL to make sure any watchdog in the user application is fed during processes that can take some time (e.g. searching for a network). If no watchdog is present, simply use stub functions.

The QSL is currently meant to be run in a single threaded environment, thus you can just use stub functions for the prototypes in dn_lock.h. If you wish to run the QSL in a multi-threaded environment, you should create your own mutex (separate from the prototypes in dn_lock.h) to be locked/unlocked before/after calls to the QSL API.

 

Expand
titleClick here to expand more details about the functions you have to implement...
Panel

C Library Specific

Refer to the dustcloud documentation for further details on how to port the prototypes in these headers.

QuickStart Library Specific

Code Block
languagecpp
titledn_time.h
uint32_t dn_time_ms(void):
void dn_sleep_ms(uint32_t milliseconds);

These functions allows the QSL to perform timing, schedule tasks and sleep to save power.

  • time_ms: Simply needs to return time in milliseconds. The absolute value is irrelevant; as long as the time returned from subsequent calls will differ by the actual time passed between them.
  • sleep_ms: Make the CPU sleep for the set number of milliseconds.

 

Code Block
languagecpp
titledn_watchdog.h
void dn_watchdog_feed(void);

This function allows the QSL to make sure any watchdog in the user application is fed during processes that can take some time (e.g. searching for a network).

  • watchdog_feed: Feed any watchdog that might be implemented in the platform; simply use stub function if none.

 

Install FTDI Serial Drivers

Install FTDI Serial Drivers
Anchor
sec_serialDrivers
sec_serialDrivers

To be able to connect to and configure the mote and manager, your computer will need the necessary FTDI Serial Drivers. Most modern OSes come with FTDI drivers pre-installed (e.g. Linux), but you may have to install them manually if they do not configure automatically when you plug in the interface board or manager. Follow the installation guide corresponding to your OS if you have any trouble.

...

The ports of interest are the third and fourth, which map to the CLI and API, respectively, as defined by Table 1

 



 

Device

Device

Anchor
tab_serialPorts
tab_serialPorts

Serial Port NumberUsageBaudrateData BitsParityStop Bits
SmartMesh IP Managerthird*CLI96008No1
fourth*API115200**8**No**1**
SmartMesh IP Motethird*CLI96008No1
fourth*API115200**8**No**1**
 


Table 1: Serial port configurations

...


Note that for Windows, the COM port assignment will change whenever you connect the interface board (or manager) to a different USB port.

Prepare Mote

4.1 Select Slave Mode

 

moteInterface2PCImage Removed

 

Figure 1: DC9003 mote board (left) connected to a computer via the DC9006 interface board (center).

 

By default, the motes in starter kits are configured for master mode; a demo mode where the API is disabled and an application is run that generates sample data and controls joining. To use the mote alongside an external MCU, the mote has to be configured for slave mode; the API is enabled and the mote expects a serially attached application to control it.

  1. Start by connecting the mote to your computer via the interface board, as shown in Figure 1.
  2. Identify the port name that maps to the CLI. For example, if you are in Windows and see the four COM ports pictured below, the CLI will be accessible through COM14.
    Image Removed 
  3. Connect to the mote CLI with a third-party serial terminal of your choice (e.g. putty). See Table 1 for configuration details.
  4. Use the get mode command to see the current mode:

     

    > get mode
    master
  5. Use the set mode command to switch to slave mode, followed by reset for the change to take effect. After rebooting, a new get mode should confirm the persistent mode change.

     

    > set mode slave
     
    > reset
      
    > SmartMesh IP mote, ver 1.3.3.1 (0x100)
    > get mode
    slave
  6. Disconnect the mote from the interface board and make sure to remove its battery (if any), as we will power the mote from the MCU.

4.2 Connect to Your Microcontroller

You will need to connect 4 wires between your MCU and the mote for power and serial communication, as shown in Table 2. In addition you need to ground the mote RX Request to Send (RTS) and TX Clear to Send (CTS); unless your MCU cannot wake on data and has to use these accordingly (the mote does not need incoming flow control).

Table 3 lists the names (equal to those found on the silkscreen) of the P1 pin header on the DC9003A mote board visible in Figure 2.

 

 

MCU
Mote
3.3 VVBAT
GroundGND
UART TXRX
UART RXTX

 

Table 2: MCU to mote pin mapping.

 

 

 

NamePin #Name
TX CTSn12TX RTSn
TX34GND
RX56RX RTSn
RX CTSn78CO TX
CO RX910GND
RESETn1112F P ENn
I MISO1314I MOSI
I SSn1516I SCK
GND1718TCK
TMS1920TDO
TDI2122VUSB_3V6
PGOOD2324GND
VBAT2526KEY
EHORBAT2728RSVD
I/O 12930I/O 2
V+3132+5V

 

Table 3: DC9003A (mote) P1 Pins

 

 

Image Removed
Figure 2: The DC9003A (mote) with the P1 pin header marked in red.

 

Prepare Manager

Image Removed
Figure 3: The DC2274A SmartMesh IP USB Manager

...

USB port

...

Similar to the mote via the interface board, you should now see 4 new serial ports, where the third and fourth give you access to the CLI and API, respectively.

5.1 Factory Default Values

By default the manager is shipped with a well-known network ID and join key that your application will need to connect to its network, so you do not need to configure anything. However, it is useful to know about certain commands available through the CLI. These commands are presented in the next section, while relevant default values for its configuration parameters are listed in Table 4.

 

 

...

Parameter

...

Comment

...

Default Value

...

 

Table 4: Relevant factory default values for the SmartMesh IP Manager

Refer to the SmartMesh IP User's Guide for a complete list of default configuration parameters for the manager.

 

5.2 Useful CLI Commands

With the manager connected to your computer via USB:

...

Unlike the mote, you will first have to login to have access to the commands we want:

...

 

...

> login user
  

...

titleClick here to expand the CLI commands...

...

sm: Displays information about the motes in the network. The manager itself will always be the first one listed (with MoteID 1)

Code Block
languagetext
titleShow Motes
> sm
     MAC                MoteId  State Nbrs Links Joins    Age StateTime
00-17-0D-00-00-60-39-35    1     Oper    1    21     1      0    4-05:25:14
00-17-0D-00-00-58-63-C1    2     Oper    1     9    49      4    0-00:28:39

...

trace motest on: Turns on a trace which shows mote state transitions as they connect to or drop from the network.

Code Block
languagetext
titleTrace Mote States On
> trace motest on

> 103190771 : Mote #2 State:   Lost -> Negot1
> 103192421 : Mote #2 State: Negot1 -> Negot2
> 103195937 : Mote #2 State: Negot2 ->  Conn1
> 103197989 : Mote #2 State:  Conn1 ->  Conn2
> 103202092 : Mote #2 State:  Conn2 ->   Oper

...

.

...

Code Block
languagetext
titleSet Configuration Parameter: Network ID
> set config netid=1229

...

show config: Show the persistent configuration parameters

Code Block
languagetext
titleShow Configuration
> show config
netid = 1229
txpower = 8
frprofile = 1
maxmotes = 33
basebw = 9000
dnfr_mult = 1
numparents = 2
cca = 0
channellist = 00:00:7f:ff
autostart = 1
locmode = 0
bbmode = 0
bbsize = 1
license = 00:00:00:00:00:00:00:00:00:00:00:00:00
ip6prefix = fe:80:00:00:00:00:00:00:00:00:00:00:00:00:00:00
ip6mask = ff:ff:ff:ff:ff:ff:ff:ff:00:00:00:00:00:00:00:00
radiotest = 0
bwmult = 300
onechannel = 255

...

set acl mac=<macAddr> key=<joinKey>: Add an Access Control List entry for the given MAC address and mote specific join key. This change is persistent, but only takes affect after a reboot.

Code Block
languagetext
titleAdd ACL Entry
> set acl mac=01-23-45-67-89-AB-CD-EF key=000102030405060708090A0B0C0D0E0F
Set OK

...

show acl: Show the motes currently whitelisted on the manager Access Control List.

Code Block
languagetext
titleShow ACL
> show acl
ACL:
    MAC: 01-23-45-67-89-AB-CD-EF
----

...

delete acl <macAddress | all>: Remove all entries in the Access Control List or the one specified by the given MAC address.

Code Block
languagetext
titleDelete ACL Entry
> delete acl all
Delete all ACL records

...

reset system: Software reset (reboot) of the manager.

Code Block
languagetext
titleReset Manager
> reset system
Reset initiating. Please wait

> Disconnecting; 1
 70978 : Lost
 71702 : Lost
 72425 : Lost
 73148 : Lost
 73871 : Lost
 74594 : Lost
 75318 : Lost
SmartMesh IP Manager ver 1.2.4.1.  (x100)
   829 : **** AP connected. Network started
Info

Refer to the SmartMesh IP Embedded Manager CLI Guide for a complete list of available CLI parameters for the manager.

...