diff --git a/sm_clib/dn_clib_build.h b/sm_clib/dn_clib_build.h index 23d1272..e1abaf9 100644 --- a/sm_clib/dn_clib_build.h +++ b/sm_clib/dn_clib_build.h @@ -4,5 +4,5 @@ enum { // This is the build number used on the next release. - VER_BUILD = 4 + VER_BUILD = 5 }; diff --git a/sm_clib/dn_ipmg.c b/sm_clib/dn_ipmg.c index 6b43d96..61e52bc 100644 --- a/sm_clib/dn_ipmg.c +++ b/sm_clib/dn_ipmg.c @@ -170,7 +170,7 @@ dn_err_t dn_ipmg_reset(uint8_t type, uint8_t* macAddress, dn_ipmg_reset_rpt* rep ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -273,7 +273,7 @@ dn_err_t dn_ipmg_subscribe(uint32_t filter, uint32_t unackFilter, dn_ipmg_subscr ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -292,10 +292,7 @@ void dn_ipmg_subscribe_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_ return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_subscribe_rpt*)dn_ipmg_vars.replyContents; @@ -359,7 +356,7 @@ dn_err_t dn_ipmg_getTime(dn_ipmg_getTime_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -410,13 +407,12 @@ void dn_ipmg_getTime_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t /** The setNetworkConfig command changes network configuration parameters. The -response code indicates whether the changes were successfully applied.This +response code indicates whether the changes were successfully applied. This change is persistent. Generally, changes to network configuration will take effect when the manager reboots. Exceptions are detailed below: - - Max Motes: The new maxMotes value is used as soon as new motes try to join the network, but motes are not removed from the network if the value is set to a number lower than numMotes. @@ -474,7 +470,7 @@ dn_err_t dn_ipmg_setNetworkConfig(uint16_t networkId, int8_t apTxPower, uint8_t ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -493,10 +489,7 @@ void dn_ipmg_setNetworkConfig_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setNetworkConfig_rpt*)dn_ipmg_vars.replyContents; @@ -557,7 +550,7 @@ dn_err_t dn_ipmg_clearStatistics(dn_ipmg_clearStatistics_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -576,10 +569,7 @@ void dn_ipmg_clearStatistics_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_clearStatistics_rpt*)dn_ipmg_vars.replyContents; @@ -645,7 +635,7 @@ dn_err_t dn_ipmg_exchangeMoteJoinKey(uint8_t* macAddress, uint8_t* key, dn_ipmg_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -732,7 +722,7 @@ dn_err_t dn_ipmg_exchangeNetworkId(uint16_t id, dn_ipmg_exchangeNetworkId_rpt* r ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -873,7 +863,7 @@ dn_err_t dn_ipmg_radiotestTx(uint8_t testType, uint16_t chanMask, uint16_t repea ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -892,10 +882,7 @@ void dn_ipmg_radiotestTx_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_radiotestTx_rpt*)dn_ipmg_vars.replyContents; @@ -971,7 +958,7 @@ dn_err_t dn_ipmg_radiotestRx(uint16_t mask, uint16_t duration, uint8_t stationId ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -990,10 +977,7 @@ void dn_ipmg_radiotestRx_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_radiotestRx_rpt*)dn_ipmg_vars.replyContents; @@ -1055,7 +1039,7 @@ dn_err_t dn_ipmg_getRadiotestStatistics(dn_ipmg_getRadiotestStatistics_rpt* repl ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1142,7 +1126,7 @@ dn_err_t dn_ipmg_setACLEntry(uint8_t* macAddress, uint8_t* joinKey, dn_ipmg_setA ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1161,10 +1145,7 @@ void dn_ipmg_setACLEntry_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setACLEntry_rpt*)dn_ipmg_vars.replyContents; @@ -1230,7 +1211,7 @@ dn_err_t dn_ipmg_getNextACLEntry(uint8_t* macAddress, dn_ipmg_getNextACLEntry_rp ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1317,7 +1298,7 @@ dn_err_t dn_ipmg_deleteACLEntry(uint8_t* macAddress, dn_ipmg_deleteACLEntry_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1336,10 +1317,7 @@ void dn_ipmg_deleteACLEntry_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, u return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_deleteACLEntry_rpt*)dn_ipmg_vars.replyContents; @@ -1405,7 +1383,7 @@ dn_err_t dn_ipmg_pingMote(uint8_t* macAddress, dn_ipmg_pingMote_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1490,7 +1468,7 @@ dn_err_t dn_ipmg_getLog(uint8_t* macAddress, dn_ipmg_getLog_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1509,10 +1487,7 @@ void dn_ipmg_getLog_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t l return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_getLog_rpt*)dn_ipmg_vars.replyContents; @@ -1589,7 +1564,7 @@ dn_err_t dn_ipmg_sendData(uint8_t* macAddress, uint8_t priority, uint16_t srcPor ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1675,7 +1650,7 @@ dn_err_t dn_ipmg_startNetwork(dn_ipmg_startNetwork_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1694,10 +1669,7 @@ void dn_ipmg_startNetwork_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uin return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_startNetwork_rpt*)dn_ipmg_vars.replyContents; @@ -1758,7 +1730,7 @@ dn_err_t dn_ipmg_getSystemInfo(dn_ipmg_getSystemInfo_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1858,7 +1830,7 @@ dn_err_t dn_ipmg_getMoteConfig(uint8_t* macAddress, bool next, dn_ipmg_getMoteCo ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -1948,7 +1920,7 @@ dn_err_t dn_ipmg_getPathInfo(uint8_t* source, uint8_t* dest, dn_ipmg_getPathInfo ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2044,7 +2016,7 @@ dn_err_t dn_ipmg_getNextPathInfo(uint8_t* macAddress, uint8_t filter, uint16_t p ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2137,7 +2109,7 @@ dn_err_t dn_ipmg_setAdvertising(uint8_t activate, dn_ipmg_setAdvertising_rpt* re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2227,7 +2199,7 @@ dn_err_t dn_ipmg_setDownstreamFrameMode(uint8_t frameMode, dn_ipmg_setDownstream ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2312,7 +2284,7 @@ dn_err_t dn_ipmg_getManagerStatistics(dn_ipmg_getManagerStatistics_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2414,7 +2386,7 @@ dn_err_t dn_ipmg_setTime(uint8_t trigger, uint8_t* utcSecs, uint32_t utcUsecs, d ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2433,10 +2405,7 @@ void dn_ipmg_setTime_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setTime_rpt*)dn_ipmg_vars.replyContents; @@ -2496,7 +2465,7 @@ dn_err_t dn_ipmg_getLicense(dn_ipmg_getLicense_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2583,7 +2552,7 @@ dn_err_t dn_ipmg_setLicense(uint8_t* license, dn_ipmg_setLicense_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2602,10 +2571,7 @@ void dn_ipmg_setLicense_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setLicense_rpt*)dn_ipmg_vars.replyContents; @@ -2628,8 +2594,8 @@ void dn_ipmg_setLicense_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 //===== setCLIUser /** -The setUser command sets the password that must be used to log into the command -line for a particular user role. The user roles are: +The setCLIUser command sets the password that must be used to log into the +command line for a particular user role. The user roles are: - Viewer - read-only access to non-sensitive information - User - read-write access This change is persistent. @@ -2671,7 +2637,7 @@ dn_err_t dn_ipmg_setCLIUser(uint8_t role, uint8_t* password, dn_ipmg_setCLIUser_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2690,10 +2656,7 @@ void dn_ipmg_setCLIUser_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setCLIUser_rpt*)dn_ipmg_vars.replyContents; @@ -2769,7 +2732,7 @@ dn_err_t dn_ipmg_sendIP(uint8_t* macAddress, uint8_t priority, uint8_t options, ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2854,7 +2817,7 @@ dn_err_t dn_ipmg_restoreFactoryDefaults(dn_ipmg_restoreFactoryDefaults_rpt* repl ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -2873,10 +2836,7 @@ void dn_ipmg_restoreFactoryDefaults_reply(uint8_t cmdId, uint8_t rc, uint8_t* pa return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_restoreFactoryDefaults_rpt*)dn_ipmg_vars.replyContents; @@ -2937,7 +2897,7 @@ dn_err_t dn_ipmg_getMoteInfo(uint8_t* macAddress, dn_ipmg_getMoteInfo_rpt* reply ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3030,7 +2990,7 @@ dn_err_t dn_ipmg_getNetworkConfig(dn_ipmg_getNetworkConfig_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3128,7 +3088,7 @@ dn_err_t dn_ipmg_getNetworkInfo(dn_ipmg_getNetworkInfo_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3223,7 +3183,7 @@ dn_err_t dn_ipmg_getMoteConfigById(uint16_t moteId, dn_ipmg_getMoteConfigById_rp ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3313,7 +3273,7 @@ dn_err_t dn_ipmg_setCommonJoinKey(uint8_t* key, dn_ipmg_setCommonJoinKey_rpt* re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3332,10 +3292,7 @@ void dn_ipmg_setCommonJoinKey_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setCommonJoinKey_rpt*)dn_ipmg_vars.replyContents; @@ -3396,7 +3353,7 @@ dn_err_t dn_ipmg_getIPConfig(dn_ipmg_getIPConfig_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3485,7 +3442,7 @@ dn_err_t dn_ipmg_setIPConfig(uint8_t* ipv6Address, uint8_t* mask, dn_ipmg_setIPC ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3504,10 +3461,7 @@ void dn_ipmg_setIPConfig_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_setIPConfig_rpt*)dn_ipmg_vars.replyContents; @@ -3569,7 +3523,7 @@ dn_err_t dn_ipmg_deleteMote(uint8_t* macAddress, dn_ipmg_deleteMote_rpt* reply) ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } @@ -3588,10 +3542,7 @@ void dn_ipmg_deleteMote_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmg_deleteMote_rpt*)dn_ipmg_vars.replyContents; @@ -3658,7 +3609,7 @@ dn_err_t dn_ipmg_getMoteLinks(uint8_t* macAddress, uint16_t idx, dn_ipmg_getMote ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmg_vars.busyTx = TRUE; } diff --git a/sm_clib/dn_ipmt.c b/sm_clib/dn_ipmt.c index 26581d7..b563547 100644 --- a/sm_clib/dn_ipmt.c +++ b/sm_clib/dn_ipmt.c @@ -74,6 +74,7 @@ void dn_ipmt_sendTo_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t l void dn_ipmt_search_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_ipmt_testRadioTxExt_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_ipmt_zeroize_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); +void dn_ipmt_socketInfo_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); // serial RX void dn_ipmt_rxSerialRequest(uint8_t cmdId, uint8_t flags, uint8_t* payload, uint8_t len); @@ -159,7 +160,7 @@ dn_err_t dn_ipmt_setParameter_macAddress(uint8_t* macAddress, dn_ipmt_setParamet ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -255,7 +256,7 @@ dn_err_t dn_ipmt_setParameter_joinKey(uint8_t* joinKey, dn_ipmt_setParameter_joi ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -354,7 +355,7 @@ dn_err_t dn_ipmt_setParameter_networkId(uint16_t networkId, dn_ipmt_setParameter ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -452,7 +453,7 @@ dn_err_t dn_ipmt_setParameter_txPower(int8_t txPower, dn_ipmt_setParameter_txPow ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -509,7 +510,8 @@ the ratio of active listen time to doze time (a low-power radio state) during the period when the mote is searching for the network. If you desire a faster join time at the risk of higher power consumption, use the setParameter command to increase the join duty cycle up to 100%. -This setting is persistent and requires a reset to take effect. +This setting is persistent and takes effect immediately if the device is +searching for network. */ dn_err_t dn_ipmt_setParameter_joinDutyCycle(uint8_t dutyCycle, dn_ipmt_setParameter_joinDutyCycle_rpt* reply) { uint8_t extraFlags; @@ -549,7 +551,7 @@ dn_err_t dn_ipmt_setParameter_joinDutyCycle(uint8_t dutyCycle, dn_ipmt_setParame ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -647,7 +649,7 @@ dn_err_t dn_ipmt_setParameter_eventMask(uint32_t eventMask, dn_ipmt_setParameter ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -741,7 +743,7 @@ dn_err_t dn_ipmt_setParameter_OTAPLockout(bool mode, dn_ipmt_setParameter_OTAPLo ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -835,7 +837,7 @@ dn_err_t dn_ipmt_setParameter_routingMode(bool mode, dn_ipmt_setParameter_routin ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -938,7 +940,7 @@ dn_err_t dn_ipmt_setParameter_powerSrcInfo(uint16_t maxStCurrent, uint8_t minLif ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1037,7 +1039,7 @@ dn_err_t dn_ipmt_setParameter_autoJoin(bool mode, dn_ipmt_setParameter_autoJoin_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1130,7 +1132,7 @@ dn_err_t dn_ipmt_getParameter_macAddress(dn_ipmt_getParameter_macAddress_rpt* re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1222,7 +1224,7 @@ dn_err_t dn_ipmt_getParameter_networkId(dn_ipmt_getParameter_networkId_rpt* repl ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1314,7 +1316,7 @@ dn_err_t dn_ipmt_getParameter_txPower(dn_ipmt_getParameter_txPower_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1406,7 +1408,7 @@ dn_err_t dn_ipmt_getParameter_joinDutyCycle(dn_ipmt_getParameter_joinDutyCycle_r ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1499,7 +1501,7 @@ dn_err_t dn_ipmt_getParameter_eventMask(dn_ipmt_getParameter_eventMask_rpt* repl ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1592,7 +1594,7 @@ dn_err_t dn_ipmt_getParameter_moteInfo(dn_ipmt_getParameter_moteInfo_rpt* reply) ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1693,7 +1695,7 @@ dn_err_t dn_ipmt_getParameter_netInfo(dn_ipmt_getParameter_netInfo_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1789,7 +1791,7 @@ dn_err_t dn_ipmt_getParameter_moteStatus(dn_ipmt_getParameter_moteStatus_rpt* re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1889,7 +1891,7 @@ dn_err_t dn_ipmt_getParameter_time(dn_ipmt_getParameter_time_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -1986,7 +1988,7 @@ dn_err_t dn_ipmt_getParameter_charge(dn_ipmt_getParameter_charge_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2083,7 +2085,7 @@ dn_err_t dn_ipmt_getParameter_testRadioRxStats(dn_ipmt_getParameter_testRadioRxS ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2177,7 +2179,7 @@ dn_err_t dn_ipmt_getParameter_OTAPLockout(dn_ipmt_getParameter_OTAPLockout_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2270,7 +2272,7 @@ dn_err_t dn_ipmt_getParameter_moteId(dn_ipmt_getParameter_moteId_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2363,7 +2365,7 @@ dn_err_t dn_ipmt_getParameter_ipv6Address(dn_ipmt_getParameter_ipv6Address_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2456,7 +2458,7 @@ dn_err_t dn_ipmt_getParameter_routingMode(dn_ipmt_getParameter_routingMode_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2548,7 +2550,7 @@ dn_err_t dn_ipmt_getParameter_powerSrcInfo(dn_ipmt_getParameter_powerSrcInfo_rpt ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2651,7 +2653,7 @@ dn_err_t dn_ipmt_getParameter_autoJoin(dn_ipmt_getParameter_autoJoin_rpt* reply) ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2744,7 +2746,7 @@ dn_err_t dn_ipmt_join(dn_ipmt_join_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2763,10 +2765,7 @@ void dn_ipmt_join_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_join_rpt*)dn_ipmt_vars.replyContents; @@ -2830,7 +2829,7 @@ dn_err_t dn_ipmt_disconnect(dn_ipmt_disconnect_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2849,10 +2848,7 @@ void dn_ipmt_disconnect_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_disconnect_rpt*)dn_ipmt_vars.replyContents; @@ -2915,7 +2911,7 @@ dn_err_t dn_ipmt_reset(dn_ipmt_reset_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -2934,10 +2930,7 @@ void dn_ipmt_reset_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t le return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_reset_rpt*)dn_ipmt_vars.replyContents; @@ -3003,7 +2996,7 @@ dn_err_t dn_ipmt_lowPowerSleep(dn_ipmt_lowPowerSleep_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3022,10 +3015,7 @@ void dn_ipmt_lowPowerSleep_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, ui return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_lowPowerSleep_rpt*)dn_ipmt_vars.replyContents; @@ -3056,9 +3046,10 @@ getParameter command. The testRadioRx command may only be issued in Idle mode. The mote must be reset (either hardware or software reset) after radio tests are complete and prior to joining. -The station ID is a user selectable value. It must be set to match the station -ID used by the transmitter. Station ID is used to isolate traffic if multiple -tests are running in the same radio space. +Station ID is available in IP mote >= 1.4, and WirelessHART mote >= 1.1.2. The +station ID is a user selectable value used to isolate traffic if multiple tests +are running in the same radio space. It must be set to match the station ID +used by the transmitter. @@ -3102,7 +3093,7 @@ dn_err_t dn_ipmt_testRadioRx(uint16_t channelMask, uint16_t time, uint8_t statio ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3121,10 +3112,7 @@ void dn_ipmt_testRadioRx_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_testRadioRx_rpt*)dn_ipmt_vars.replyContents; @@ -3187,7 +3175,7 @@ dn_err_t dn_ipmt_clearNV(dn_ipmt_clearNV_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3206,10 +3194,7 @@ void dn_ipmt_clearNV_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_clearNV_rpt*)dn_ipmt_vars.replyContents; @@ -3278,7 +3263,7 @@ dn_err_t dn_ipmt_requestService(uint16_t destAddr, uint8_t serviceType, uint32_t ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3297,10 +3282,7 @@ void dn_ipmt_requestService_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, u return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_requestService_rpt*)dn_ipmt_vars.replyContents; @@ -3363,7 +3345,7 @@ dn_err_t dn_ipmt_getServiceInfo(uint16_t destAddr, uint8_t type, dn_ipmt_getServ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3451,7 +3433,7 @@ dn_err_t dn_ipmt_openSocket(uint8_t protocol, dn_ipmt_openSocket_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3535,7 +3517,7 @@ dn_err_t dn_ipmt_closeSocket(uint8_t socketId, dn_ipmt_closeSocket_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3554,10 +3536,7 @@ void dn_ipmt_closeSocket_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_closeSocket_rpt*)dn_ipmt_vars.replyContents; @@ -3621,7 +3600,7 @@ dn_err_t dn_ipmt_bindSocket(uint8_t socketId, uint16_t port, dn_ipmt_bindSocket_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3640,10 +3619,7 @@ void dn_ipmt_bindSocket_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_bindSocket_rpt*)dn_ipmt_vars.replyContents; @@ -3717,7 +3693,7 @@ dn_err_t dn_ipmt_sendTo(uint8_t socketId, uint8_t* destIP, uint16_t destPort, ui ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3736,10 +3712,7 @@ void dn_ipmt_sendTo_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t l return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_sendTo_rpt*)dn_ipmt_vars.replyContents; @@ -3803,7 +3776,7 @@ dn_err_t dn_ipmt_search(dn_ipmt_search_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3822,10 +3795,7 @@ void dn_ipmt_search_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t l return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_search_rpt*)dn_ipmt_vars.replyContents; @@ -3947,7 +3917,7 @@ dn_err_t dn_ipmt_testRadioTxExt(uint8_t testType, uint16_t chanMask, uint16_t re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -3966,10 +3936,7 @@ void dn_ipmt_testRadioTxExt_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, u return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_ipmt_testRadioTxExt_rpt*)dn_ipmt_vars.replyContents; @@ -4035,7 +4002,7 @@ dn_err_t dn_ipmt_zeroize(dn_ipmt_zeroize_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_ipmt_vars.busyTx = TRUE; } @@ -4054,13 +4021,93 @@ void dn_ipmt_zeroize_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t return; } - // verify length + // do NOT verify length (no return fields expected) + + // cast the replyContent + reply = (dn_ipmt_zeroize_rpt*)dn_ipmt_vars.replyContents; + + // store RC + reply->RC = rc; + + // parse returned value (iff RC==0) if (rc==DN_SERIAL_RC_OK) { + + } + + // call the callback + dn_ipmt_vars.replyCb(cmdId); + + // I'm not busy transmitting anymore + dn_ipmt_vars.busyTx=FALSE; +} + +//===== socketInfo + +/** +Retrieve information about a socket. (Available in IP Mote >= 1.4.0) +*/ +dn_err_t dn_ipmt_socketInfo(uint8_t index, dn_ipmt_socketInfo_rpt* reply) { + uint8_t extraFlags; + dn_err_t rc; + + // lock the module + dn_lock(); + + // verify no ongoing transmissions + if (dn_ipmt_vars.busyTx) { + // unlock the module + dn_unlock(); + + // return + return DN_ERR_BUSY; + } + + // store callback information + dn_ipmt_vars.cmdId = CMDID_SOCKETINFO; + dn_ipmt_vars.replyContents = (uint8_t*)reply; + + // extraFlags + extraFlags = 0x00; + + // build outputBuf + dn_ipmt_vars.outputBuf[DN_SOCKETINFO_REQ_OFFS_INDEX] = index; + + // send outputBuf + rc = dn_serial_mt_sendRequest( + CMDID_SOCKETINFO, // cmdId + extraFlags, // extraFlags + dn_ipmt_vars.outputBuf, // payload + DN_SOCKETINFO_REQ_LEN, // length + dn_ipmt_socketInfo_reply // replyCb + ); + + if (rc==DN_ERR_NONE) { + // I'm now busy transmitting + dn_ipmt_vars.busyTx = TRUE; + } + + // unlock the module + dn_unlock(); + + return rc; + +} + +void dn_ipmt_socketInfo_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len) { + dn_ipmt_socketInfo_rpt* reply; + + // verify I'm expecting this answer + if (dn_ipmt_vars.busyTx==FALSE || dn_ipmt_vars.cmdId!=cmdId) { + return; + } + + // verify length + if (rc==DN_SERIAL_RC_OK && lenRC = rc; @@ -4068,6 +4115,11 @@ void dn_ipmt_zeroize_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t // parse returned value (iff RC==0) if (rc==DN_SERIAL_RC_OK) { + reply->index = payload[DN_SOCKETINFO_REPLY_OFFS_INDEX]; + reply->socketId = payload[DN_SOCKETINFO_REPLY_OFFS_SOCKETID]; + reply->protocol = payload[DN_SOCKETINFO_REPLY_OFFS_PROTOCOL]; + reply->bindState = payload[DN_SOCKETINFO_REPLY_OFFS_BINDSTATE]; + dn_read_uint16_t(&reply->port,&payload[DN_SOCKETINFO_REPLY_OFFS_PORT]); } // call the callback @@ -4150,6 +4202,7 @@ void dn_ipmt_rxSerialRequest(uint8_t cmdId, uint8_t flags, uint8_t* payload, uin notif_receive->socketId = payload[DN_RECEIVE_NOTIF_OFFS_SOCKETID]; memcpy(¬if_receive->srcAddr[0],&payload[DN_RECEIVE_NOTIF_OFFS_SRCADDR],16); dn_read_uint16_t(¬if_receive->srcPort,&payload[DN_RECEIVE_NOTIF_OFFS_SRCPORT]); + notif_receive->payloadLen = len-DN_RECEIVE_NOTIF_OFFS_PAYLOAD; memcpy(¬if_receive->payload[0],&payload[DN_RECEIVE_NOTIF_OFFS_PAYLOAD],len-DN_RECEIVE_NOTIF_OFFS_PAYLOAD); break; case CMDID_MACRX: diff --git a/sm_clib/dn_ipmt.h b/sm_clib/dn_ipmt.h index 3c683e7..ecf0a00 100644 --- a/sm_clib/dn_ipmt.h +++ b/sm_clib/dn_ipmt.h @@ -42,6 +42,7 @@ static const uint8_t ipv6Addr_manager[16] = { #define CMDID_SEARCH 0x24 #define CMDID_TESTRADIOTXEXT 0x28 #define CMDID_ZEROIZE 0x29 +#define CMDID_SOCKETINFO 0x2b //===== command IDs (notifications) #define CMDID_TIMEINDICATION 0xd @@ -264,6 +265,10 @@ static const uint8_t ipv6Addr_manager[16] = { // zeroize #define DN_ZEROIZE_REQ_LEN 0 +// socketInfo +#define DN_SOCKETINFO_REQ_OFFS_INDEX 0 +#define DN_SOCKETINFO_REQ_LEN 1 + //===== format of replies // setParameter_macAddress @@ -448,6 +453,14 @@ static const uint8_t ipv6Addr_manager[16] = { // zeroize #define DN_ZEROIZE_REPLY_LEN 0 +// socketInfo +#define DN_SOCKETINFO_REPLY_OFFS_INDEX 0 +#define DN_SOCKETINFO_REPLY_OFFS_SOCKETID 1 +#define DN_SOCKETINFO_REPLY_OFFS_PROTOCOL 2 +#define DN_SOCKETINFO_REPLY_OFFS_BINDSTATE 3 +#define DN_SOCKETINFO_REPLY_OFFS_PORT 4 +#define DN_SOCKETINFO_REPLY_LEN 6 + //===== format of notifications // timeIndication @@ -715,6 +728,15 @@ typedef struct { uint8_t RC; } dn_ipmt_zeroize_rpt; +typedef struct { + uint8_t RC; + uint8_t index; + uint8_t socketId; + uint8_t protocol; + uint8_t bindState; + uint16_t port; +} dn_ipmt_socketInfo_rpt; + //=== notification types typedef struct { @@ -735,6 +757,7 @@ typedef struct { uint8_t socketId; uint8_t srcAddr[16]; uint16_t srcPort; + uint8_t payloadLen; uint8_t payload[MAX_FRAME_LENGTH]; } dn_ipmt_receive_nt; @@ -815,6 +838,7 @@ dn_err_t dn_ipmt_sendTo(uint8_t socketId, uint8_t* destIP, uint16_t destPort, ui dn_err_t dn_ipmt_search(dn_ipmt_search_rpt* reply); dn_err_t dn_ipmt_testRadioTxExt(uint8_t testType, uint16_t chanMask, uint16_t repeatCnt, int8_t txPower, uint8_t seqSize, uint8_t pkLen_1, uint16_t delay_1, uint8_t pkLen_2, uint16_t delay_2, uint8_t pkLen_3, uint16_t delay_3, uint8_t pkLen_4, uint16_t delay_4, uint8_t pkLen_5, uint16_t delay_5, uint8_t pkLen_6, uint16_t delay_6, uint8_t pkLen_7, uint16_t delay_7, uint8_t pkLen_8, uint16_t delay_8, uint8_t pkLen_9, uint16_t delay_9, uint8_t pkLen_10, uint16_t delay_10, uint8_t stationId, dn_ipmt_testRadioTxExt_rpt* reply); dn_err_t dn_ipmt_zeroize(dn_ipmt_zeroize_rpt* reply); +dn_err_t dn_ipmt_socketInfo(uint8_t index, dn_ipmt_socketInfo_rpt* reply); #ifdef __cplusplus } diff --git a/sm_clib/dn_whmt.c b/sm_clib/dn_whmt.c index b1a5571..1bfd99f 100644 --- a/sm_clib/dn_whmt.c +++ b/sm_clib/dn_whmt.c @@ -59,6 +59,7 @@ void dn_whmt_setNVParameter_ttl_reply(uint8_t cmdId, uint8_t rc, uint8_t* payloa void dn_whmt_setNVParameter_HARTantennaGain_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_setNVParameter_OTAPlockout_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_setNVParameter_hrCounterMode_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); +void dn_whmt_setNVParameter_autojoin_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_setNVParameter_compliantMode_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_setNVParameter_lock_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_getNVParameter_macAddress_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); @@ -69,6 +70,7 @@ void dn_whmt_getNVParameter_ttl_reply(uint8_t cmdId, uint8_t rc, uint8_t* payloa void dn_whmt_getNVParameter_HARTantennaGain_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_getNVParameter_OTAPlockout_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_getNVParameter_hrCounterMode_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); +void dn_whmt_getNVParameter_autojoin_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_getNVParameter_compliantMode_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_getNVParameter_lock_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); void dn_whmt_send_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len); @@ -179,7 +181,7 @@ dn_err_t dn_whmt_setParameter_txPower(int8_t txPower, dn_whmt_setParameter_txPow ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -282,7 +284,7 @@ dn_err_t dn_whmt_setParameter_joinDutyCycle(uint8_t dutyCycle, dn_whmt_setParame ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -382,7 +384,7 @@ dn_err_t dn_whmt_setParameter_batteryLife(uint16_t batteryLife, uint8_t powerSta ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -501,7 +503,7 @@ dn_err_t dn_whmt_setParameter_service(uint8_t serviceId, uint8_t serviceReqFlags ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -598,7 +600,7 @@ dn_err_t dn_whmt_setParameter_hartDeviceStatus(uint8_t hartDevStatus, dn_whmt_se ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -694,7 +696,7 @@ dn_err_t dn_whmt_setParameter_hartDeviceInfo(uint8_t* hartCmd0, uint8_t* hartCmd ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -795,7 +797,7 @@ dn_err_t dn_whmt_setParameter_eventMask(uint32_t eventMask, dn_whmt_setParameter ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -895,7 +897,7 @@ dn_err_t dn_whmt_setParameter_writeProtect(uint8_t writeProtect, dn_whmt_setPara ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -994,7 +996,7 @@ dn_err_t dn_whmt_setParameter_lock(uint8_t code, uint16_t master, dn_whmt_setPar ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1088,7 +1090,7 @@ dn_err_t dn_whmt_getParameter_joinDutyCycle(dn_whmt_getParameter_joinDutyCycle_r ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1185,7 +1187,7 @@ dn_err_t dn_whmt_getParameter_service(uint8_t serviceId, dn_whmt_getParameter_se ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1284,7 +1286,7 @@ dn_err_t dn_whmt_getParameter_moteInfo(dn_whmt_getParameter_moteInfo_rpt* reply) ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1385,7 +1387,7 @@ dn_err_t dn_whmt_getParameter_networkInfo(dn_whmt_getParameter_networkInfo_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1482,7 +1484,7 @@ dn_err_t dn_whmt_getParameter_moteStatus(dn_whmt_getParameter_moteStatus_rpt* re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1579,7 +1581,7 @@ dn_err_t dn_whmt_getParameter_time(dn_whmt_getParameter_time_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1675,7 +1677,7 @@ dn_err_t dn_whmt_getParameter_charge(dn_whmt_getParameter_charge_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1773,7 +1775,7 @@ dn_err_t dn_whmt_getParameter_testRadioRxStats(dn_whmt_getParameter_testRadioRxS ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1869,7 +1871,7 @@ dn_err_t dn_whmt_getParameter_lock(dn_whmt_getParameter_lock_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -1967,7 +1969,7 @@ dn_err_t dn_whmt_setNVParameter_macAddress(uint8_t memory, uint8_t* macAddr, dn_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2066,7 +2068,7 @@ dn_err_t dn_whmt_setNVParameter_joinKey(uint8_t memory, uint8_t* joinKey, dn_whm ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2174,7 +2176,7 @@ dn_err_t dn_whmt_setNVParameter_networkId(uint8_t memory, uint16_t networkId, dn ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2277,7 +2279,7 @@ dn_err_t dn_whmt_setNVParameter_txPower(uint8_t memory, int8_t txPower, dn_whmt_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2378,7 +2380,7 @@ dn_err_t dn_whmt_setNVParameter_powerInfo(uint8_t memory, uint8_t powerSource, u ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2484,7 +2486,7 @@ dn_err_t dn_whmt_setNVParameter_ttl(uint8_t memory, uint8_t timeToLive, dn_whmt_ ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2586,7 +2588,7 @@ dn_err_t dn_whmt_setNVParameter_HARTantennaGain(uint8_t memory, int8_t antennaGa ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2690,7 +2692,7 @@ dn_err_t dn_whmt_setNVParameter_OTAPlockout(uint8_t memory, uint8_t otapLockout, ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2792,7 +2794,7 @@ dn_err_t dn_whmt_setNVParameter_hrCounterMode(uint8_t memory, uint8_t hrCounterM ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2841,6 +2843,111 @@ void dn_whmt_setNVParameter_hrCounterMode_reply(uint8_t cmdId, uint8_t rc, uint8 dn_whmt_vars.busyTx=FALSE; } +//===== setNVParameter_autojoin + +/** +The setNVParameter command allows the microprocessor to change +between automatic and manual joining by the mote's networking stack. In manual +mode, an explicit join command from the application is required to initiate +joining. This setting is persistent and takes effect after mote reset. + +Note that auto join mode must not be set if the application is also configured +to join (e.g combining 'auto join' with 'master' mode will result in mote not +joining). +*/ +dn_err_t dn_whmt_setNVParameter_autojoin(uint8_t memory, uint32_t reserved, uint8_t nvParamId, uint8_t autojoin, dn_whmt_setNVParameter_autojoin_rpt* reply) { + uint8_t extraFlags; + dn_err_t rc; + + // lock the module + dn_lock(); + + // verify no ongoing transmissions + if (dn_whmt_vars.busyTx) { + // unlock the module + dn_unlock(); + + // return + return DN_ERR_BUSY; + } + + // store callback information + dn_whmt_vars.cmdId = CMDID_SETNVPARAMETER; + dn_whmt_vars.replyContents = (uint8_t*)reply; + dn_whmt_vars.paramId = PARAMID_AUTOJOIN; + + // extraFlags + extraFlags = 0x00; + if (memory==DN_MEMORY_NV_RAM) { + extraFlags |= (1<<7); + } + + // build outputBuf + dn_whmt_vars.outputBuf[0] = PARAMID_AUTOJOIN; + dn_write_uint32_t(&dn_whmt_vars.outputBuf[DN_SETNVPARAMETER_AUTOJOIN_REQ_OFFS_RESERVED],reserved); + dn_whmt_vars.outputBuf[DN_SETNVPARAMETER_AUTOJOIN_REQ_OFFS_NVPARAMID] = nvParamId; + dn_whmt_vars.outputBuf[DN_SETNVPARAMETER_AUTOJOIN_REQ_OFFS_AUTOJOIN] = autojoin; + + // send outputBuf + rc = dn_serial_mt_sendRequest( + CMDID_SETNVPARAMETER, // cmdId + extraFlags, // extraFlags + dn_whmt_vars.outputBuf, // payload + DN_SETNVPARAMETER_AUTOJOIN_REQ_LEN, // length + dn_whmt_setNVParameter_autojoin_reply // replyCb + ); + + if (rc==DN_ERR_NONE) { + // I'm now busy transmitting + dn_whmt_vars.busyTx = TRUE; + } + + // unlock the module + dn_unlock(); + + return rc; + +} + +void dn_whmt_setNVParameter_autojoin_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len) { + dn_whmt_setNVParameter_autojoin_rpt* reply; + uint8_t paramId; + + // verify I'm expecting this answer + if (dn_whmt_vars.busyTx==FALSE || dn_whmt_vars.cmdId!=cmdId) { + return; + } + + // verify I'm expecting this paramId + paramId = payload[0]; + if (paramId!=dn_whmt_vars.paramId) { + return; + } + + // verify length + if (rc==DN_SERIAL_RC_OK && lenRC = rc; + + // parse returned value (iff RC==0) + if (rc==DN_SERIAL_RC_OK) { + + reply->nvParamId = payload[DN_SETNVPARAMETER_AUTOJOIN_REPLY_OFFS_NVPARAMID]; + } + + // call the callback + dn_whmt_vars.replyCb(cmdId); + + // I'm not busy transmitting anymore + dn_whmt_vars.busyTx=FALSE; +} + //===== setNVParameter_compliantMode /** @@ -2894,7 +3001,7 @@ dn_err_t dn_whmt_setNVParameter_compliantMode(uint8_t memory, uint8_t compliantM ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -2997,7 +3104,7 @@ dn_err_t dn_whmt_setNVParameter_lock(uint8_t memory, uint8_t code, uint16_t mast ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3093,7 +3200,7 @@ dn_err_t dn_whmt_getNVParameter_macAddress(dn_whmt_getNVParameter_macAddress_rpt ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3186,7 +3293,7 @@ dn_err_t dn_whmt_getNVParameter_networkId(dn_whmt_getNVParameter_networkId_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3279,7 +3386,7 @@ dn_err_t dn_whmt_getNVParameter_txPower(dn_whmt_getNVParameter_txPower_rpt* repl ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3372,7 +3479,7 @@ dn_err_t dn_whmt_getNVParameter_powerInfo(dn_whmt_getNVParameter_powerInfo_rpt* ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3470,7 +3577,7 @@ dn_err_t dn_whmt_getNVParameter_ttl(dn_whmt_getNVParameter_ttl_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3565,7 +3672,7 @@ dn_err_t dn_whmt_getNVParameter_HARTantennaGain(dn_whmt_getNVParameter_HARTanten ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3659,7 +3766,7 @@ dn_err_t dn_whmt_getNVParameter_OTAPlockout(dn_whmt_getNVParameter_OTAPlockout_r ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3755,7 +3862,7 @@ dn_err_t dn_whmt_getNVParameter_hrCounterMode(dn_whmt_getNVParameter_hrCounterMo ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3805,6 +3912,103 @@ void dn_whmt_getNVParameter_hrCounterMode_reply(uint8_t cmdId, uint8_t rc, uint8 dn_whmt_vars.busyTx=FALSE; } +//===== getNVParameter_autojoin + +/** +The getNVParameter command returns the autojoin status stored in +mote's persistent storage (i.e. set with setNVParameter). Autojoin +can be used to cause a mote in slave mode to join on its own when booted. +*/ +dn_err_t dn_whmt_getNVParameter_autojoin(uint32_t reserved, uint8_t nvParamId, dn_whmt_getNVParameter_autojoin_rpt* reply) { + uint8_t extraFlags; + dn_err_t rc; + + // lock the module + dn_lock(); + + // verify no ongoing transmissions + if (dn_whmt_vars.busyTx) { + // unlock the module + dn_unlock(); + + // return + return DN_ERR_BUSY; + } + + // store callback information + dn_whmt_vars.cmdId = CMDID_GETNVPARAMETER; + dn_whmt_vars.replyContents = (uint8_t*)reply; + dn_whmt_vars.paramId = PARAMID_AUTOJOIN; + + // extraFlags + extraFlags = 0x00; + + // build outputBuf + dn_whmt_vars.outputBuf[0] = PARAMID_AUTOJOIN; + dn_write_uint32_t(&dn_whmt_vars.outputBuf[DN_GETNVPARAMETER_AUTOJOIN_REQ_OFFS_RESERVED],reserved); + dn_whmt_vars.outputBuf[DN_GETNVPARAMETER_AUTOJOIN_REQ_OFFS_NVPARAMID] = nvParamId; + + // send outputBuf + rc = dn_serial_mt_sendRequest( + CMDID_GETNVPARAMETER, // cmdId + extraFlags, // extraFlags + dn_whmt_vars.outputBuf, // payload + DN_GETNVPARAMETER_AUTOJOIN_REQ_LEN, // length + dn_whmt_getNVParameter_autojoin_reply // replyCb + ); + + if (rc==DN_ERR_NONE) { + // I'm now busy transmitting + dn_whmt_vars.busyTx = TRUE; + } + + // unlock the module + dn_unlock(); + + return rc; + +} + +void dn_whmt_getNVParameter_autojoin_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len) { + dn_whmt_getNVParameter_autojoin_rpt* reply; + uint8_t paramId; + + // verify I'm expecting this answer + if (dn_whmt_vars.busyTx==FALSE || dn_whmt_vars.cmdId!=cmdId) { + return; + } + + // verify I'm expecting this paramId + paramId = payload[0]; + if (paramId!=dn_whmt_vars.paramId) { + return; + } + + // verify length + if (rc==DN_SERIAL_RC_OK && lenRC = rc; + + // parse returned value (iff RC==0) + if (rc==DN_SERIAL_RC_OK) { + + reply->nvParamId = payload[DN_GETNVPARAMETER_AUTOJOIN_REPLY_OFFS_NVPARAMID]; + reply->autojoin = payload[DN_GETNVPARAMETER_AUTOJOIN_REPLY_OFFS_AUTOJOIN]; + } + + // call the callback + dn_whmt_vars.replyCb(cmdId); + + // I'm not busy transmitting anymore + dn_whmt_vars.busyTx=FALSE; +} + //===== getNVParameter_compliantMode /** @@ -3855,7 +4059,7 @@ dn_err_t dn_whmt_getNVParameter_compliantMode(dn_whmt_getNVParameter_compliantMo ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -3950,7 +4154,7 @@ dn_err_t dn_whmt_getNVParameter_lock(dn_whmt_getNVParameter_lock_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4071,7 +4275,7 @@ dn_err_t dn_whmt_send(bool tranType, bool tranDir, uint16_t destAddr, uint8_t se ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4090,10 +4294,7 @@ void dn_whmt_send_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_send_rpt*)dn_whmt_vars.replyContents; @@ -4157,7 +4358,7 @@ dn_err_t dn_whmt_join(dn_whmt_join_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4176,10 +4377,7 @@ void dn_whmt_join_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t len return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_join_rpt*)dn_whmt_vars.replyContents; @@ -4251,7 +4449,7 @@ dn_err_t dn_whmt_disconnect(dn_whmt_disconnect_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4270,10 +4468,7 @@ void dn_whmt_disconnect_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8 return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_disconnect_rpt*)dn_whmt_vars.replyContents; @@ -4335,7 +4530,7 @@ dn_err_t dn_whmt_reset(dn_whmt_reset_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4354,10 +4549,7 @@ void dn_whmt_reset_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t le return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_reset_rpt*)dn_whmt_vars.replyContents; @@ -4430,7 +4622,7 @@ dn_err_t dn_whmt_lowPowerSleep(dn_whmt_lowPowerSleep_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4449,10 +4641,7 @@ void dn_whmt_lowPowerSleep_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, ui return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_lowPowerSleep_rpt*)dn_whmt_vars.replyContents; @@ -4521,7 +4710,7 @@ dn_err_t dn_whmt_hartPayload(uint8_t payloadLen, uint8_t* payload, dn_whmt_hartP ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4624,7 +4813,7 @@ dn_err_t dn_whmt_testRadioTx(uint8_t channel, uint16_t numPackets, dn_whmt_testR ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4643,10 +4832,7 @@ void dn_whmt_testRadioTx_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_testRadioTx_rpt*)dn_whmt_vars.replyContents; @@ -4720,7 +4906,7 @@ dn_err_t dn_whmt_testRadioRx(uint8_t channel, uint16_t time, dn_whmt_testRadioRx ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4739,10 +4925,7 @@ void dn_whmt_testRadioRx_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_testRadioRx_rpt*)dn_whmt_vars.replyContents; @@ -4806,7 +4989,7 @@ dn_err_t dn_whmt_clearNV(dn_whmt_clearNV_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4825,10 +5008,7 @@ void dn_whmt_clearNV_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_clearNV_rpt*)dn_whmt_vars.replyContents; @@ -4893,7 +5073,7 @@ dn_err_t dn_whmt_search(dn_whmt_search_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -4912,10 +5092,7 @@ void dn_whmt_search_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t l return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_search_rpt*)dn_whmt_vars.replyContents; @@ -5037,7 +5214,7 @@ dn_err_t dn_whmt_testRadioTxExt(uint8_t testType, uint16_t chanMask, uint16_t re ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -5056,10 +5233,7 @@ void dn_whmt_testRadioTxExt_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, u return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_testRadioTxExt_rpt*)dn_whmt_vars.replyContents; @@ -5089,9 +5263,10 @@ During the test, the mote keeps statistics about the number of packets received getParameter command.The mote must be reset (either hardware or software reset) after radio tests are complete and prior to joining. -The station ID is a user selectable value. It must be set to match the station -ID used by the transmitter. Station ID is used to isolate traffic if multiple -tests are running in the same radio space. +Station ID is available in IP mote >= 1.4, and WirelessHART mote >= 1.1.2. The +station ID is a user selectable value used to isolate traffic if multiple tests +are running in the same radio space. It must be set to match the station ID +used by the transmitter. @@ -5135,7 +5310,7 @@ dn_err_t dn_whmt_testRadioRxExt(uint16_t channelMask, uint16_t time, uint8_t sta ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -5154,10 +5329,7 @@ void dn_whmt_testRadioRxExt_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, u return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_testRadioRxExt_rpt*)dn_whmt_vars.replyContents; @@ -5223,7 +5395,7 @@ dn_err_t dn_whmt_zeroize(dn_whmt_zeroize_rpt* reply) { ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -5242,10 +5414,7 @@ void dn_whmt_zeroize_reply(uint8_t cmdId, uint8_t rc, uint8_t* payload, uint8_t return; } - // verify length - if (rc==DN_SERIAL_RC_OK) { - return; - } + // do NOT verify length (no return fields expected) // cast the replyContent reply = (dn_whmt_zeroize_rpt*)dn_whmt_vars.replyContents; @@ -5311,7 +5480,7 @@ dn_err_t dn_whmt_fileWrite(int32_t descriptor, uint16_t offset, uint8_t length, ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -5399,7 +5568,7 @@ dn_err_t dn_whmt_fileRead(int32_t descriptor, uint16_t offset, uint8_t length, d ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -5490,7 +5659,7 @@ dn_err_t dn_whmt_fileOpen(uint8_t* name, uint8_t options, uint16_t size, uint8_t ); if (rc==DN_ERR_NONE) { - // I'm not busy transmitting + // I'm now busy transmitting dn_whmt_vars.busyTx = TRUE; } @@ -5641,7 +5810,7 @@ void dn_whmt_rxSerialRequest(uint8_t cmdId, uint8_t flags, uint8_t* payload, uin // parse the notification dn_read_uint16_t(¬if_dataReceived->srcAddr,&payload[DN_DATARECEIVED_NOTIF_OFFS_SRCADDR]); notif_dataReceived->seqNum = payload[DN_DATARECEIVED_NOTIF_OFFS_SEQNUM]; - notif_dataReceived->pktLenth = payload[DN_DATARECEIVED_NOTIF_OFFS_PKTLENTH]; + notif_dataReceived->pktLength = payload[DN_DATARECEIVED_NOTIF_OFFS_PKTLENGTH]; memcpy(¬if_dataReceived->data[0],&payload[DN_DATARECEIVED_NOTIF_OFFS_DATA],len-DN_DATARECEIVED_NOTIF_OFFS_DATA); break; case CMDID_ADVRECEIVED: diff --git a/sm_clib/dn_whmt.h b/sm_clib/dn_whmt.h index 6069478..16103f6 100644 --- a/sm_clib/dn_whmt.h +++ b/sm_clib/dn_whmt.h @@ -81,6 +81,7 @@ C library to connect to a SmartMesh WirelessHART Mote. #define PARAMID_HARTANTENNAGAIN 0x14 #define PARAMID_OTAPLOCKOUT 0x15 #define PARAMID_HRCOUNTERMODE 0x17 +#define PARAMID_AUTOJOIN 0x18 #define PARAMID_COMPLIANTMODE 0x19 #define PARAMID_LOCK 0x1a @@ -196,6 +197,12 @@ C library to connect to a SmartMesh WirelessHART Mote. #define DN_SETNVPARAMETER_HRCOUNTERMODE_REQ_OFFS_HRCOUNTERMODE 1 #define DN_SETNVPARAMETER_HRCOUNTERMODE_REQ_LEN 2 +// setNVParameter_autojoin +#define DN_SETNVPARAMETER_AUTOJOIN_REQ_OFFS_RESERVED 1 +#define DN_SETNVPARAMETER_AUTOJOIN_REQ_OFFS_NVPARAMID 5 +#define DN_SETNVPARAMETER_AUTOJOIN_REQ_OFFS_AUTOJOIN 6 +#define DN_SETNVPARAMETER_AUTOJOIN_REQ_LEN 7 + // setNVParameter_compliantMode #define DN_SETNVPARAMETER_COMPLIANTMODE_REQ_OFFS_COMPLIANTMODE 1 #define DN_SETNVPARAMETER_COMPLIANTMODE_REQ_LEN 2 @@ -229,6 +236,11 @@ C library to connect to a SmartMesh WirelessHART Mote. // getNVParameter_hrCounterMode #define DN_GETNVPARAMETER_HRCOUNTERMODE_REQ_LEN 1 +// getNVParameter_autojoin +#define DN_GETNVPARAMETER_AUTOJOIN_REQ_OFFS_RESERVED 1 +#define DN_GETNVPARAMETER_AUTOJOIN_REQ_OFFS_NVPARAMID 5 +#define DN_GETNVPARAMETER_AUTOJOIN_REQ_LEN 6 + // getNVParameter_compliantMode #define DN_GETNVPARAMETER_COMPLIANTMODE_REQ_LEN 1 @@ -456,6 +468,10 @@ C library to connect to a SmartMesh WirelessHART Mote. // setNVParameter_hrCounterMode #define DN_SETNVPARAMETER_HRCOUNTERMODE_REPLY_LEN 1 +// setNVParameter_autojoin +#define DN_SETNVPARAMETER_AUTOJOIN_REPLY_OFFS_NVPARAMID 1 +#define DN_SETNVPARAMETER_AUTOJOIN_REPLY_LEN 2 + // setNVParameter_compliantMode #define DN_SETNVPARAMETER_COMPLIANTMODE_REPLY_LEN 1 @@ -497,6 +513,11 @@ C library to connect to a SmartMesh WirelessHART Mote. #define DN_GETNVPARAMETER_HRCOUNTERMODE_REPLY_OFFS_HRCOUNTERMODE 1 #define DN_GETNVPARAMETER_HRCOUNTERMODE_REPLY_LEN 2 +// getNVParameter_autojoin +#define DN_GETNVPARAMETER_AUTOJOIN_REPLY_OFFS_NVPARAMID 1 +#define DN_GETNVPARAMETER_AUTOJOIN_REPLY_OFFS_AUTOJOIN 2 +#define DN_GETNVPARAMETER_AUTOJOIN_REPLY_LEN 3 + // getNVParameter_compliantMode #define DN_GETNVPARAMETER_COMPLIANTMODE_REPLY_OFFS_COMPLIANTMODE 1 #define DN_GETNVPARAMETER_COMPLIANTMODE_REPLY_LEN 2 @@ -591,7 +612,7 @@ C library to connect to a SmartMesh WirelessHART Mote. // dataReceived #define DN_DATARECEIVED_NOTIF_OFFS_SRCADDR 0 #define DN_DATARECEIVED_NOTIF_OFFS_SEQNUM 2 -#define DN_DATARECEIVED_NOTIF_OFFS_PKTLENTH 3 +#define DN_DATARECEIVED_NOTIF_OFFS_PKTLENGTH 3 #define DN_DATARECEIVED_NOTIF_OFFS_DATA 4 #define DN_DATARECEIVED_NOTIF_LEN 4 @@ -754,6 +775,11 @@ typedef struct { uint8_t RC; } dn_whmt_setNVParameter_hrCounterMode_rpt; +typedef struct { + uint8_t RC; + uint8_t nvParamId; +} dn_whmt_setNVParameter_autojoin_rpt; + typedef struct { uint8_t RC; } dn_whmt_setNVParameter_compliantMode_rpt; @@ -805,6 +831,12 @@ typedef struct { uint8_t hrCounterMode; } dn_whmt_getNVParameter_hrCounterMode_rpt; +typedef struct { + uint8_t RC; + uint8_t nvParamId; + uint8_t autojoin; +} dn_whmt_getNVParameter_autojoin_rpt; + typedef struct { uint8_t RC; uint8_t compliantMode; @@ -919,7 +951,7 @@ typedef struct { uint8_t tranDir; uint16_t srcAddr; uint8_t seqNum; - uint8_t pktLenth; + uint8_t pktLength; uint8_t data[MAX_FRAME_LENGTH]; } dn_whmt_dataReceived_nt; @@ -980,6 +1012,7 @@ dn_err_t dn_whmt_setNVParameter_ttl(uint8_t memory, uint8_t timeToLive, dn_whmt_ dn_err_t dn_whmt_setNVParameter_HARTantennaGain(uint8_t memory, int8_t antennaGain, dn_whmt_setNVParameter_HARTantennaGain_rpt* reply); dn_err_t dn_whmt_setNVParameter_OTAPlockout(uint8_t memory, uint8_t otapLockout, dn_whmt_setNVParameter_OTAPlockout_rpt* reply); dn_err_t dn_whmt_setNVParameter_hrCounterMode(uint8_t memory, uint8_t hrCounterMode, dn_whmt_setNVParameter_hrCounterMode_rpt* reply); +dn_err_t dn_whmt_setNVParameter_autojoin(uint8_t memory, uint32_t reserved, uint8_t nvParamId, uint8_t autojoin, dn_whmt_setNVParameter_autojoin_rpt* reply); dn_err_t dn_whmt_setNVParameter_compliantMode(uint8_t memory, uint8_t compliantMode, dn_whmt_setNVParameter_compliantMode_rpt* reply); dn_err_t dn_whmt_setNVParameter_lock(uint8_t memory, uint8_t code, uint16_t master, dn_whmt_setNVParameter_lock_rpt* reply); dn_err_t dn_whmt_getNVParameter_macAddress(dn_whmt_getNVParameter_macAddress_rpt* reply); @@ -990,6 +1023,7 @@ dn_err_t dn_whmt_getNVParameter_ttl(dn_whmt_getNVParameter_ttl_rpt* reply); dn_err_t dn_whmt_getNVParameter_HARTantennaGain(dn_whmt_getNVParameter_HARTantennaGain_rpt* reply); dn_err_t dn_whmt_getNVParameter_OTAPlockout(dn_whmt_getNVParameter_OTAPlockout_rpt* reply); dn_err_t dn_whmt_getNVParameter_hrCounterMode(dn_whmt_getNVParameter_hrCounterMode_rpt* reply); +dn_err_t dn_whmt_getNVParameter_autojoin(uint32_t reserved, uint8_t nvParamId, dn_whmt_getNVParameter_autojoin_rpt* reply); dn_err_t dn_whmt_getNVParameter_compliantMode(dn_whmt_getNVParameter_compliantMode_rpt* reply); dn_err_t dn_whmt_getNVParameter_lock(dn_whmt_getNVParameter_lock_rpt* reply); dn_err_t dn_whmt_send(bool tranType, bool tranDir, uint16_t destAddr, uint8_t serviceId, uint8_t appDomain, uint8_t priority, uint16_t reserved, uint8_t seqNum, uint8_t payloadLen, uint8_t* payload, dn_whmt_send_rpt* reply);