Program that uses the QuickStart Library to interface a SmartMesh IP mote: Connects to the default network and starts publishing a random walk value every 5 seconds.

Dependencies:   mbed millis

Fork of QSL_SimplePublish by Jon-Håkon Bøe Røli

QSL SimplePublish

SmartMesh IP QuickStart Library

Committer:
jhbr
Date:
Thu Sep 01 15:00:28 2016 +0000
Revision:
1:89766ea2e99d
Parent:
dn_qsl_api.h@0:d3f5fdf2e6da
Moved QSL and C Library files to separate folders

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhbr 0:d3f5fdf2e6da 1 /*
jhbr 0:d3f5fdf2e6da 2 Copyright (c) 2016, Dust Networks. All rights reserved.
jhbr 0:d3f5fdf2e6da 3
jhbr 0:d3f5fdf2e6da 4 QuickStart Library API.
jhbr 0:d3f5fdf2e6da 5
jhbr 0:d3f5fdf2e6da 6 \license See attached DN_LICENSE.txt.
jhbr 0:d3f5fdf2e6da 7 */
jhbr 0:d3f5fdf2e6da 8
jhbr 0:d3f5fdf2e6da 9 #ifndef DN_QSL_API_H
jhbr 0:d3f5fdf2e6da 10 #define DN_QSL_API_H
jhbr 0:d3f5fdf2e6da 11
jhbr 0:d3f5fdf2e6da 12 #include "dn_common.h"
jhbr 0:d3f5fdf2e6da 13 #include "dn_defaults.h"
jhbr 0:d3f5fdf2e6da 14
jhbr 0:d3f5fdf2e6da 15 //=========================== defines =========================================
jhbr 0:d3f5fdf2e6da 16
jhbr 0:d3f5fdf2e6da 17 #define DN_DEST_IP DN_DEFAULT_DEST_IP
jhbr 0:d3f5fdf2e6da 18
jhbr 0:d3f5fdf2e6da 19 //=========================== typedef =========================================
jhbr 0:d3f5fdf2e6da 20
jhbr 0:d3f5fdf2e6da 21 //=========================== variables =======================================
jhbr 0:d3f5fdf2e6da 22
jhbr 0:d3f5fdf2e6da 23 //=========================== prototypes ======================================
jhbr 0:d3f5fdf2e6da 24
jhbr 0:d3f5fdf2e6da 25 #ifdef __cplusplus
jhbr 0:d3f5fdf2e6da 26 extern "C" {
jhbr 0:d3f5fdf2e6da 27 #endif
jhbr 0:d3f5fdf2e6da 28
jhbr 0:d3f5fdf2e6da 29 //===== init
jhbr 0:d3f5fdf2e6da 30
jhbr 0:d3f5fdf2e6da 31 /**
jhbr 0:d3f5fdf2e6da 32 \brief Initialize the necessary structures and underlying C Library.
jhbr 0:d3f5fdf2e6da 33
jhbr 0:d3f5fdf2e6da 34 Has to be run once before any of the other functions below is run.
jhbr 0:d3f5fdf2e6da 35
jhbr 0:d3f5fdf2e6da 36 \return A boolean indicating the success of the initialization.
jhbr 0:d3f5fdf2e6da 37 */
jhbr 0:d3f5fdf2e6da 38 bool dn_qsl_init(void);
jhbr 0:d3f5fdf2e6da 39
jhbr 0:d3f5fdf2e6da 40
jhbr 0:d3f5fdf2e6da 41 //===== isConnected
jhbr 0:d3f5fdf2e6da 42
jhbr 0:d3f5fdf2e6da 43 /**
jhbr 0:d3f5fdf2e6da 44 \brief Return TRUE if the mote is connected to a network.
jhbr 0:d3f5fdf2e6da 45
jhbr 0:d3f5fdf2e6da 46 Simply checks if the FSM is in the CONNECTED state.
jhbr 0:d3f5fdf2e6da 47
jhbr 0:d3f5fdf2e6da 48 \return A boolean indicating if the mote is connected to a network.
jhbr 0:d3f5fdf2e6da 49 */
jhbr 0:d3f5fdf2e6da 50 bool dn_qsl_isConnected(void);
jhbr 0:d3f5fdf2e6da 51
jhbr 0:d3f5fdf2e6da 52
jhbr 0:d3f5fdf2e6da 53 //===== connect
jhbr 0:d3f5fdf2e6da 54
jhbr 0:d3f5fdf2e6da 55 /**
jhbr 0:d3f5fdf2e6da 56 \brief Attempt to make the mote connect to a network with the given parameters.
jhbr 0:d3f5fdf2e6da 57
jhbr 0:d3f5fdf2e6da 58 If the passed network ID, join key or source port is zero/NULL, default values
jhbr 0:d3f5fdf2e6da 59 are used. If non-zero, the passed service will be requested after joining a
jhbr 0:d3f5fdf2e6da 60 network. A new service can be requested later by calling connect again with the
jhbr 0:d3f5fdf2e6da 61 same network ID, join key and source port. Further, if the requested service is
jhbr 0:d3f5fdf2e6da 62 also indifferent, the function simply returns TRUE.
jhbr 0:d3f5fdf2e6da 63
jhbr 0:d3f5fdf2e6da 64 \param netID The ID of the network to attempt to connect with.
jhbr 0:d3f5fdf2e6da 65 \param joinKey The join key to use in the connection attempt.
jhbr 0:d3f5fdf2e6da 66 \param srcPort The port that you expect to get downstream data on.
jhbr 0:d3f5fdf2e6da 67 \param service_ms The service to request after establishing a connection, given in milliseconds.
jhbr 0:d3f5fdf2e6da 68 \return A boolean indicating if the connection attempt and/or service request was successful.
jhbr 0:d3f5fdf2e6da 69 */
jhbr 0:d3f5fdf2e6da 70 bool dn_qsl_connect(uint16_t netID, const uint8_t* joinKey, uint16_t srcPort, uint32_t service_ms);
jhbr 0:d3f5fdf2e6da 71
jhbr 0:d3f5fdf2e6da 72
jhbr 0:d3f5fdf2e6da 73 //===== send
jhbr 0:d3f5fdf2e6da 74
jhbr 0:d3f5fdf2e6da 75 /**
jhbr 0:d3f5fdf2e6da 76 \brief Send a packet into the network.
jhbr 0:d3f5fdf2e6da 77
jhbr 0:d3f5fdf2e6da 78 Tells the mote send a packet with the given payload into the network.
jhbr 0:d3f5fdf2e6da 79 Said packet is sent to the provided destination port (default if 0) and the
jhbr 0:d3f5fdf2e6da 80 IPv6 address defined by DEST_IP (default is the well-known manager address).
jhbr 0:d3f5fdf2e6da 81 The FSM waits for a confirmation from the mote that the packet was accepted
jhbr 0:d3f5fdf2e6da 82 and queued up for transmission. Note that end-to-end delivery is not
jhbr 0:d3f5fdf2e6da 83 guaranteed with the utilized UDP, but reliability is typically > 99.9 %.
jhbr 0:d3f5fdf2e6da 84
jhbr 0:d3f5fdf2e6da 85 \param payload Pointer to a byte array containing the payload.
jhbr 0:d3f5fdf2e6da 86 \param payloadSize_B Byte size of the payload.
jhbr 0:d3f5fdf2e6da 87 \param destPort The destination port for the packet.
jhbr 0:d3f5fdf2e6da 88 \return A boolean indicating if the packet was queued up for transmission.
jhbr 0:d3f5fdf2e6da 89 */
jhbr 0:d3f5fdf2e6da 90 bool dn_qsl_send(const uint8_t* payload, uint8_t payloadSize_B, uint16_t destPort);
jhbr 0:d3f5fdf2e6da 91
jhbr 0:d3f5fdf2e6da 92
jhbr 0:d3f5fdf2e6da 93 //===== read
jhbr 0:d3f5fdf2e6da 94
jhbr 0:d3f5fdf2e6da 95 /**
jhbr 0:d3f5fdf2e6da 96 \brief Read the FIFO buffered inbox of downstream messages.
jhbr 0:d3f5fdf2e6da 97
jhbr 0:d3f5fdf2e6da 98 As the payload of downstream messages are pushed into a buffered FIFO inbox,
jhbr 0:d3f5fdf2e6da 99 calling this function will pop the first one (oldest) stored into the provided
jhbr 0:d3f5fdf2e6da 100 buffer and return the byte size. An empty inbox will simply return 0.
jhbr 0:d3f5fdf2e6da 101
jhbr 0:d3f5fdf2e6da 102 \param readBuffer Pointer to a byte array to store the read message payload.
jhbr 0:d3f5fdf2e6da 103 \return The number of bytes read into the provided buffer.
jhbr 0:d3f5fdf2e6da 104 */
jhbr 0:d3f5fdf2e6da 105 uint8_t dn_qsl_read(uint8_t* readBuffer);
jhbr 0:d3f5fdf2e6da 106
jhbr 0:d3f5fdf2e6da 107 #ifdef __cplusplus
jhbr 0:d3f5fdf2e6da 108 }
jhbr 0:d3f5fdf2e6da 109 #endif
jhbr 0:d3f5fdf2e6da 110
jhbr 0:d3f5fdf2e6da 111 #endif