initUpon startup, this always has to be run once. It will initialize the necessary structures and underlying modules, essentially establishing a serial connection to the Mote. Parameters: None Returns: Boolean indicating the success of the initialization. However, currently it will always return TRUE: The underlying init functions of the SmartMesh C Library does not have any return values (it is still included for forward compatability if these init functions are changed to include return values). isConnectedSimple TRUE/FALSE query to QSL if the mote is currently connected to the SMIP network and ready to send/receive data. This way, the user application can check if it should reconnect (call connect again) in the case of a failed send (or if the send simply failed). Parameters: None Returns: Booleanindicating if the mote is connected to a network. connectRun after a successful init to make the mote search and join a network with the given network ID and join key, followed by requesting the given service. Further, a socket is opened and bound to the given port, ready to send/receive user data. Subsequent calls to connect while still connected has a few different behaviours based on the parameter values: - A different network ID, join key and/or port will cause the mote to attempt to reconnect with the new parameters.
- If only the requested service is different, the mote will simply make a new request.
- If all parameters are the same, connect simply returns TRUE, essentially a way to check that the mote is still connected with the given parameters.
Parameters: - netID: The ID of the network the mote should attempt to join. If 0, the default ID is used. If 0xFFFF, the mote will join the first network heard.
- joinKey: The join key to use in the connection attempt. If NULL, the default key is used.
- srcPort: The port to expect downstream data on. If 0, the default port is used.
- service_ms: The service to request after establishing a connection, given in milliseconds. If 0, no mote specific service is requested (and the user application should adhere to the base bandwidth granted by the manager).
Returns: Boolean indicating if the mote successfully connected to a network and was granted the requested service, if any. sendIf connected to a network, the mote will send a packet with the given payload to the given port. The packet is addressed to the manager by default, but it is possible to change this to any IPv6 address with the DN_DEST_IP define (this will require that the manager is connected to a computer correctly configured as a gateway, e.g. by using DustLink). Note that end-to-end delivery is not guaranteed with the utilized UDP, but the success rate of the mesh network is typically greater than 99.9 %. Parameters: - payload: Pointer to a byte array containing the payload.
- payloadSize_B: Byte size of the payload.
- destPort: The destination port for the packet. If 0, the default port is used.
Returns: A boolean indicating if the packet was queued up for transmission at the mote. readThe payload of downstream messages are pushed into a buffered FIFO inbox as they arrive. Calling read will pop the first one (oldest) stored into the provided buffer and return the byte size; 0 indicates that the inbox is empty. As the inbox has a limited size (can be changed with the DN_INBOX_SIZE define), old data will start to drop if the user application does not make sure to call read often enough. Parameters: - readBuffer: Pointer to a byte array to store the read message payload.
Returns: The number of bytes read into the provided buffer. |