/*
* Copyright (C) 2015, 2016 "IoT.bzh"
* Author "Fulup Ar Foll"
+ * Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
init_context(context, session, token);
if (created) {
context->created = 1;
- context->refreshing = 1;
+ /* context->refreshing = 1; */
}
return 0;
}
return context->loa_in >= loa;
}
-void afb_context_change_loa(struct afb_context *context, unsigned loa)
+int afb_context_change_loa(struct afb_context *context, unsigned loa)
{
- assert(context->validated);
+ if (!context->validated || loa > 7)
+ return 0;
- if (loa == context->loa_in)
+ if (loa == context->loa_in && !context->loa_changed)
context->loa_changing = 0;
else {
- context->loa_changing = 1;
context->loa_out = loa & 7;
+ context->loa_changing = 1;
+ context->loa_changed = 0;
}
+ return 1;
}