interface FrameUtility;
interface IEEE154Frame as Frame;
interface Get<uint64_t> as LocalExtendedAddress;
- interface Ieee802154Debug as Debug;
}
}
implementation
return SUCCESS;
}
-/* ------------------- MLME_ASSOCIATE Request ------------------- */
+ /* ------------------- MLME_ASSOCIATE Request ------------------- */
command ieee154_status_t MLME_ASSOCIATE.request (
uint8_t LogicalChannel,
uint16_t CoordPANID,
ieee154_address_t CoordAddress,
ieee154_CapabilityInformation_t CapabilityInformation,
- ieee154_security_t *security
- )
+ ieee154_security_t *security)
{
ieee154_status_t status = IEEE154_SUCCESS;
ieee154_txframe_t *txFrame=0;
status = IEEE154_INVALID_PARAMETER;
else if (m_associationOngoing || !(txFrame = call TxFramePool.get()))
status = IEEE154_TRANSACTION_OVERFLOW;
- else if (!(txControl = call TxControlPool.get())){
+ else if (!(txControl = call TxControlPool.get())) {
call TxFramePool.put(txFrame);
status = IEEE154_TRANSACTION_OVERFLOW;
}
- if (status == IEEE154_SUCCESS){
+ if (status == IEEE154_SUCCESS) {
m_assocRespStatus = IEEE154_NO_DATA;
m_shortAddress = 0xFFFF;
call MLME_SET.phyCurrentChannel(LogicalChannel);
txFrame->payload = m_payloadAssocRequest;
txFrame->payloadLen = 2;
m_associationOngoing = TRUE;
- if ((status = call AssociationRequestTx.transmit(txFrame)) != IEEE154_SUCCESS){
+ if ((status = call AssociationRequestTx.transmit(txFrame)) != IEEE154_SUCCESS) {
m_associationOngoing = FALSE;
call TxFramePool.put(txFrame);
call TxControlPool.put(txControl);
}
}
- call Debug.log(LEVEL_INFO, AssociateP_REQUEST, status, 0, 0);
+ dbg_serial("AssociationP", "MLME_ASSOCIATE.request -> result: %lu\n", (uint32_t) status);
return status;
}
{
call TxControlPool.put((ieee154_txcontrol_t*) ((uint8_t*) txFrame->header - offsetof(ieee154_txcontrol_t, header)));
call TxFramePool.put(txFrame);
- if (status != IEEE154_SUCCESS){
+ if (status != IEEE154_SUCCESS) {
+ dbg_serial("AssociationP", "transmitDone() failed!\n");
m_associationOngoing = FALSE;
signal MLME_ASSOCIATE.confirm(0xFFFF, status, 0);
} else {
call ResponseTimeout.startOneShot(call MLME_GET.macResponseWaitTime()*IEEE154_aBaseSuperframeDuration);
- call Debug.log(LEVEL_INFO, AssociateP_SETTIMER,
- call MLME_GET.macResponseWaitTime()*IEEE154_aBaseSuperframeDuration, 0, 0);
+ dbg_serial("AssociationP", "transmitDone() ok, waiting for %lu\n",
+ (uint32_t) (call MLME_GET.macResponseWaitTime() * IEEE154_aBaseSuperframeDuration));
}
- call Debug.log(LEVEL_INFO, AssociateP_TXDONE, status, 0, 0);
}
event void ResponseTimeout.fired()
if (!m_associationOngoing)
return;
// have not received an AssociationResponse yet, poll the coordinator now
+ dbg_serial("AssociationP", "Polling the coordinator for an AssociationResponse now...\n");
if (m_coordAddrMode == ADDR_MODE_SHORT_ADDRESS)
*((nxle_uint16_t*) &coordAddress) = call MLME_GET.macCoordShortAddress();
else
call FrameUtility.copyCoordExtendedAddressLE(coordAddress);
if (call DataRequest.poll(m_coordAddrMode, call MLME_GET.macPANId(),
- coordAddress, ADDR_MODE_EXTENDED_ADDRESS) != IEEE154_SUCCESS){
+ coordAddress, ADDR_MODE_EXTENDED_ADDRESS) != IEEE154_SUCCESS) {
m_shortAddress = 0xFFFF;
m_assocRespStatus = IEEE154_TRANSACTION_OVERFLOW;
signal DataRequest.pollDone();
+ dbg_serial("AssociationP", "Poll failed (locally)...\n");
}
}
event message_t* AssociationResponseExtracted.received(message_t* frame, ieee154_txframe_t *txFrame)
{
uint8_t *payload = (uint8_t *) &frame->data;
- if (m_associationOngoing){
+ if (m_associationOngoing) {
m_shortAddress = *((nxle_uint16_t*) (payload + 1));
m_assocRespStatus = *(payload + 3);
}
event void DataRequest.pollDone()
{
- if (m_associationOngoing){
- call Debug.log(LEVEL_INFO, AssociateP_POLL_DONE, m_payloadAssocRequest[0], m_assocRespStatus, 0);
+ if (m_associationOngoing) {
call ResponseTimeout.stop();
m_associationOngoing = FALSE;
+ if (m_assocRespStatus == IEEE154_ASSOCIATION_SUCCESSFUL)
+ call MLME_SET.macShortAddress(m_shortAddress);
signal MLME_ASSOCIATE.confirm(m_shortAddress, m_assocRespStatus, 0);
+ dbg_serial("AssociationP", "confirm: %lx, %lu\n",
+ (uint32_t) m_shortAddress, (uint32_t) m_assocRespStatus);
}
}
-/* ------------------- MLME_ASSOCIATE Response ------------------- */
+ /* ------------------- MLME_ASSOCIATE Response ------------------- */
event message_t* AssociationRequestRx.received(message_t* frame)
{
uint64_t deviceAddress,
uint16_t assocShortAddress,
ieee154_association_status_t status,
- ieee154_security_t *security
- )
+ ieee154_security_t *security)
{
uint8_t i;
ieee154_status_t txStatus = IEEE154_SUCCESS;
for (i=0; i<MAX_PENDING_ASSOC_RESPONSES;i++)
if (m_payloadAssocResponse[i][0] == S_IDLE)
break;
- if (i == MAX_PENDING_ASSOC_RESPONSES || !(txFrame = call TxFramePool.get()))
+ if (security && security->SecurityLevel)
+ txStatus = IEEE154_UNSUPPORTED_SECURITY;
+ else if (i == MAX_PENDING_ASSOC_RESPONSES || !(txFrame = call TxFramePool.get()))
txStatus = IEEE154_TRANSACTION_OVERFLOW;
- else if (!(txControl = call TxControlPool.get())){
+ else if (!(txControl = call TxControlPool.get())) {
call TxFramePool.put(txFrame);
txStatus = IEEE154_TRANSACTION_OVERFLOW;
} else {
*((nxle_uint16_t*) &txFrame->payload[1]) = assocShortAddress;
txFrame->payload[3] = status;
txFrame->payloadLen = 4;
- if ((txStatus = call AssociationResponseTx.transmit(txFrame)) != IEEE154_SUCCESS){
+ if ((txStatus = call AssociationResponseTx.transmit(txFrame)) != IEEE154_SUCCESS) {
txFrame->payload[0] = S_IDLE;
call TxFramePool.put(txFrame);
call TxControlPool.put(txControl);
status, 0);
}
-/* ------------------- Defaults ------------------- */
+ /* ------------------- Defaults ------------------- */
default event void MLME_ASSOCIATE.indication (
uint64_t DeviceAddress,
ieee154_CapabilityInformation_t CapabilityInformation,
- ieee154_security_t *security
- ){}
+ ieee154_security_t *security) {}
default event void MLME_ASSOCIATE.confirm (
uint16_t AssocShortAddress,
uint8_t status,
- ieee154_security_t *security
- ){}
+ ieee154_security_t *security) {}
default event void MLME_COMM_STATUS.indication (
uint16_t PANId,
uint8_t SrcAddrMode,
uint8_t DstAddrMode,
ieee154_address_t DstAddr,
ieee154_status_t status,
- ieee154_security_t *security
- ){}
+ ieee154_security_t *security) {}
}