Interface: tos.interfaces.AMSend

interface AMSend

Commands
command error_t cancel(message_t *msg) Cancel a requested transmission.
command void *getPayload(message_t *msg) Return a pointer to a protocol's payload region in a packet.
command uint8_t maxPayloadLength() Return the maximum payload length that this communication layer can provide.
command error_t send(am_addr_t addr, message_t *msg, uint8_t len) Send a packet with a data payload of len to address addr.

Events
event void sendDone(message_t *msg, error_t error) Signaled in response to an accepted send request.

Commands - Details

cancel

command error_t cancel(message_t *msg)

Cancel a requested transmission. Returns SUCCESS if the transmission was canceled properly (not sent in its entirety). Note that the component may not know if the send was successfully canceled, if the radio is handling much of the logic; in this case, a component should be conservative and return an appropriate error code. A successful call to cancel must always result in a sendFailed event, and never a sendSucceeded event.

Parameters:
msg - the packet whose transmission should be cancelled.
Returns:
SUCCESS if the transmission was cancelled, FAIL otherwise.
See:
sendDone

getPayload

command void *getPayload(message_t *msg)

Return a pointer to a protocol's payload region in a packet. The length of this region is maxPayloadLength(). This command behaves similarly to Packet.getPayload (minus the length parameter) and is included in this interface as a convenience.

Parameters:
msg - the packet
Returns:
the payload of the packet

maxPayloadLength

command uint8_t maxPayloadLength()

Return the maximum payload length that this communication layer can provide. This command behaves identically to Packet.maxPayloadLength and is included in this interface as a convenience.

Returns:
the maximum payload length

send

command error_t send(am_addr_t addr, message_t *msg, uint8_t len)

Send a packet with a data payload of len to address addr. To determine the maximum available size, use the Packet interface of the component providing AMSend. If send returns SUCCESS, then the component will signal the sendDone event in the future; if send returns an error, it will not signal the event. Note that a component may accept a send request which it later finds it cannot satisfy; in this case, it will signal sendDone with error code.

Parameters:
addr - address to which to send the packet
msg - the packet
len - the length of the data in the packet payload
Returns:
SUCCESS if the request to send succeeded and a sendDone will be signaled later, EBUSY if the abstraction cannot send now but will be able to later, or FAIL if the communication layer is not in a state that can send (e.g., off).
See:
sendDone

Events - Details

sendDone

event void sendDone(message_t *msg, error_t error)

Signaled in response to an accepted send request. msg is the message buffer sent, and error indicates whether the send was successful.

Parameters:
msg - the packet which was submitted as a send request
error - SUCCESS if it was sent successfully, FAIL if it was not, ECANCEL if it was cancelled
See:
send
cancel