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