Esempio n. 1
0
void Interpreter::CacheInstances()
{
    if (mApiInstance)
    {
        otDeviceList *aDeviceList = otEnumerateDevices(mApiInstance);
        assert(aDeviceList);

        mInstancesLength = aDeviceList->aDevicesLength > MAX_CLI_OT_INSTANCES ? MAX_CLI_OT_INSTANCES
                                                                              : (uint8_t)aDeviceList->aDevicesLength;

        for (uint8_t i = 0; i < mInstancesLength; i++)
        {
            mInstances[i].mInterpreter = this;
            mInstances[i].mInstance = static_cast<Instance *>(otInstanceInit(mApiInstance, &aDeviceList->aDevices[i]));
            assert(mInstances[i].mInstance);
        }

        otFreeMemory(aDeviceList);

        if (mInstancesLength > 0)
        {
            mInstance = mInstances[0].mInstance;
        }
    }
}
Esempio n. 2
0
void Interpreter::CacheInstances()
{
    if (mApiInstance)
    {
        otDeviceList *aDeviceList = otEnumerateDevices(mApiInstance);
        assert(aDeviceList);

        mInstancesLength = aDeviceList->aDevicesLength > MAX_CLI_OT_INSTANCES ?
                            MAX_CLI_OT_INSTANCES :
                            (uint8_t)aDeviceList->aDevicesLength;

        for (uint8_t i = 0; i < mInstancesLength; i++)
        {
            mInstances[i].mInterpreter = this;
            mInstances[i].mInstance = otInstanceInit(mApiInstance, &aDeviceList->aDevices[i]);
            assert(mInstances[i].mInstance);
            otSetStateChangedCallback(mInstances[i].mInstance, &Interpreter::s_HandleNetifStateChanged, &mInstances[i]);
        }

        otFreeMemory(aDeviceList);

        if (mInstancesLength > 0) { mInstance = mInstances[0].mInstance; }
    }
}