Clean up CoAP CLI. (#1864)

- Change static methods into class methods.
- Remove client/server distinction.
- Fix callback method types and remove unnecessary type casts.
- Update README.md to reflect changes.
This commit is contained in:
Jonathan Hui
2017-06-02 08:56:47 -07:00
committed by GitHub
parent 08e352ca3e
commit 8872e292eb
5 changed files with 140 additions and 193 deletions
+6 -3
View File
@@ -223,6 +223,9 @@ typedef otPtr<const uint8_t> otBufferPtr;
typedef otPtr<const char> otStringPtr;
Interpreter::Interpreter(otInstance *aInstance):
#if OPENTHREAD_ENABLE_APPLICATION_COAP
mCoap(*this),
#endif
mServer(NULL),
#ifdef OTDLL
mApiInstance(otApiInit()),
@@ -313,7 +316,7 @@ int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
return static_cast<int>(cur - aBin);
}
void Interpreter::AppendResult(otError aError)
void Interpreter::AppendResult(otError aError) const
{
if (aError == OT_ERROR_NONE)
{
@@ -325,7 +328,7 @@ void Interpreter::AppendResult(otError aError)
}
}
void Interpreter::OutputBytes(const uint8_t *aBytes, uint8_t aLength)
void Interpreter::OutputBytes(const uint8_t *aBytes, uint8_t aLength) const
{
for (int i = 0; i < aLength; i++)
{
@@ -657,7 +660,7 @@ exit:
void Interpreter::ProcessCoap(int argc, char *argv[])
{
otError error;
error = Coap::Process(mInstance, argc, argv, *mServer);
error = mCoap.Process(argc, argv);
AppendResult(error);
}