ots-m2m / sew-lwm2m-reference-design Goto Github PK
View Code? Open in Web Editor NEWA reference implementation of the South East Water LWM2M water meter design
License: Mozilla Public License 2.0
A reference implementation of the South East Water LWM2M water meter design
License: Mozilla Public License 2.0
Clue:
__attribute__((interrupt(USCI_A0_VECTOR))) void rx_a0_isr(void)
{
extern int log_write_console_char(const char c);
log_write_console_char('x');
rx_isr(UCA0);
}
Btw... where is the dev board documentation. I should check the uart pin connection
Hi,
Regarding wiring, I can't quite figure out what type of LED should be used, i.e. what voltage and amperage?
Furthermore the potentiometer seems to be connected to a 3,3V battery? Is that correct?
And finally the pin6 Ground on the Pi, should be connected to the potentiometer, the LED and which pin on the development board?
https://github.com/ots-m2m/sew-lwm2m-reference-design/blob/master/lwm2m/event_and_alarm_base.c#L165
Resetting the stream without calling cbor_serialize_array(stream, 4);
would most likely send a invalid current type event and alarm base payload.
Put it in the root of the repository and move all #defines that can be adjusted by the user, e..g the server address, wherther to use bootstrap, maxium number of object instances etc.
In lwm2m_object_options.h, is the payload buffer size declared correctly?
#define EVENT_AND_ALARM_BASE_PAYLOAD_VALUE_ENTRY_MAX_BYTES 2
#define EVENT_AND_ALARM_BASE_PAYLOAD_OVERHEAD_MAX_BYTES 5
#define EVENT_AND_ALARM_BASE_PAYLOAD_BUFFER_SIZE_BYTES (EVENT_AND_ALARM_BASE_PAYLOAD_OVERHEAD_MAX_BYTES + EVENT_AND_ALARM_BASE_PAYLOAD_VALUE_COUNT_MAX * EVENT_AND_ALARM_BASE_PAYLOAD_VALUE_ENTRY_MAX_BYTES)
seems like a single CBOR event payload costs a lot more bytes, e.g:
cbor_serialize_array(stream, 2);
cbor_serialize_int64_t(stream, timestamp);
cbor_serialize_int(stream, (uint16_t) new_sensor_value);
Mark has found that the unit test vector was not comprehensive enough, and that there was an error caught by the integration test that the unit test did not catch. He has already fixed the issue and is requesting a fix for the unit test vector to covert this case.
{ /* Interval Data Base - Single Block */
char old_payload[] = {
0x9f, 0x19, 0x1f, 0x4a, 0x00, 0x9f, 0x9f, 0x1a, 0x05,
0x26, 0x5c, 0x00, 0x1a, 0x00, 0x01, 0x51, 0x80, 0x9f,
0x9f, 0x01, 0xff, 0x9f, 0x02, 0xff, 0x9f, 0x03, 0xff,
0x9f, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff
};
char new_payload[] = {
0x83, 0x19, 0x1f, 0x4a, 0x00, 0x83, 0x1a, 0x05, 0x26,
0x5c, 0x00, 0x1a, 0x00, 0x01, 0x51, 0x80, 0x84, 0x01,
0x02, 0x03, 0x04
};
}
{ /* Interval Data Base - Multi Block (skipped interval) */
char old_payload[] = {
0x9f, 0x19, 0x1f, 0x4a, 0x00, 0x9f, 0x9f, 0x1a, 0x05,
0x26, 0x5c, 0x00, 0x1a, 0x00, 0x01, 0x51, 0x80, 0x9f,
0x9f, 0x01, 0xff, 0x9f, 0x02, 0xff, 0xff, 0xff, 0x9f,
0x1a, 0x05, 0x2a, 0x50, 0x80, 0x1a, 0x00, 0x01, 0x51,
0x80, 0x9f, 0x9f, 0x03, 0xff, 0x9f, 0x04, 0xff, 0xff,
0xff, 0xff, 0xff
};
char new_payload[] = {
0x83, 0x19, 0x1f, 0x4a, 0x00, 0x82, 0x83, 0x1a, 0x05,
0x26, 0x5c, 0x00, 0x1a, 0x00, 0x01, 0x51, 0x80, 0x82,
0x01, 0x02, 0x83, 0x1a, 0x05, 0x2a, 0x50, 0x80, 0x1a,
0x00, 0x01, 0x51, 0x80, 0x82, 0x03, 0x04
};
}
The corrected code is below.
When result
is int. Then there is an overflow in 16bit devices.
This will need to be pushed to upstream to wakama public repo via standard submission process.
Also should investigate if uriString[*headP] != '/'
is correc. Check if prv_parseNumber()
get uriString with /
as the break char.
static int prv_parseNumber(uint8_t * uriString,
size_t uriLength,
size_t * headP)
{
uint32_t result = 0;
if (uriString[*headP] == '/')
{
// empty Object Instance ID with resource ID is not allowed
return -1;
}
while (*headP < uriLength && uriString[*headP] != '/')
{
if ('0' <= uriString[*headP] && uriString[*headP] <= '9')
{
result += uriString[*headP] - '0';
result *= 10;
}
else
{
return -1;
}
*headP += 1;
}
result /= 10;
return result;
}
During bootup I see this log:
00000000.019[I] Developed by Operational Technology Solutions
00000000.025[I] ot-solutions.com.au
00000000.029[I] ----------------------------------------
00000000.034[I] press any key to run unit tests...
00000002.039[I] skipping unit tests...
00000002.044[I] Initialising event and alarm object 0
00000002.049[W] failed to register confirmable resource since the object is not registered
00000002.058[I] Initialising Delivery Schedule object with instance id of 0
00000002.065[I] Resetting Delivery Schedule Instance 0
00000002.071[I] Initialising Event Data Delivery object with instance id of 0
00000002.078[W] failed to register confirmable resource since the object is not registered
00000002.087[D] Initialising Interval Data Delivery object with instance id of 0
00000002.095[W] failed to register confirmable resource since the object is not registered
00000002.103[I] Initialising interval data object 0
00000002.109[W] failed to register confirmable resource since the object is not registered
00000002.117[W] failed to register confirmable resource since the object is not registered
00000002.125[I] Initialising interval data object 1
00000002.131[W] failed to register confirmable resource since the object is not registered
00000002.139[W] failed to register confirmable resource since the object is not registered
00000002.150[D] slip interface initialised
00000002.164[I] Connecting to 192.168.0.17
00000002.168[D] socket 16184 created
00000002.172[D] host found at IP: 192.0.168.0
00000002.198[D] sent 191 bytes (retry 0)
00000002.202[I] --------------------------
While trying to get unit test working, I found that the timeout value in timeout_ms is always somehow interpreted as 0ms. I cant tell yet if its because of gunk uart data, or if its because of some faulty logic in this function,
int log_getchar(char *c, int timout_ms)
In base objects, we should during initialisation always check if memory is written to correctly.
This would allow for catching broken memory cells etc...
At the very least it should also test maximum and minimum data range. This would at least also assist in porting to different sized arch, to catch overflow error during unit test.
__static bool event_and_alarm_base_rate_limit_check(int32_t time_s, event_and_alarm_base_t *base_ptr)
on large time numberSome unit test is located away from the unit test. Move it to unit test folder.
parse_lwm2m_exe_arg.c
utc_offset_parser.c
Work through the setup instruction like it was a fresh installation and cleanup any information that is needed to run the demonstration.
This will need to include curl commands to configure the two demo scenarios per the demo tests in the sew-inegration test repo.
This must render cleanly in github with correct formatting etc.
need to determinw the correct codes and implement.
Design Doc should be updated
Main change is that instance ID is added
[
Object ID,
Instance ID,
[
[BLOCK0],
[BLOCK1],
...
]
]
Where a block should have
[
Interval Start Timestamp,
Interval Period,
[
[SAMPLE0],
[SAMPLE1],
[SAMPLE2],
...
]
]
Need to show how to hookup the PI, the TI Dev Board and Potentiometer for the demo to work.
Also not the MCU partno, the dev board part number etc.
/Users/briankhuu/git/sew-lwm2m-reference-design/thirdparty/lwip/src/netif/slipif.c
within while loop. possible issue with extracting multiple frames in uart stream. Since we only have one slip frame buffer.
Here it is as it currently stands
slipif_poll(struct netif *netif)
{
u8_t c;
struct slipif_priv *priv;
LWIP_ASSERT("netif != NULL", (netif != NULL));
LWIP_ASSERT("netif->state != NULL", (netif->state != NULL));
priv = (struct slipif_priv *)netif->state;
while (sio_tryread(priv->sd, &c, 1) > 0) {
slipif_rxbyte_input(netif, c);
}
}
Annotated:
/**
* Polls the serial device and feeds the IP layer with incoming packets.
*
* @param netif The lwip network interface structure for this slipif
*/
void
slipif_poll(struct netif *netif)
{
u8_t c; /* Byte Buffer */
struct slipif_priv *priv = 0;
/* Guards */
LWIP_ASSERT("netif != NULL", (netif != NULL));
LWIP_ASSERT("netif->state != NULL", (netif->state != NULL));
/* serial device handle */
priv = (struct slipif_priv *)netif->state;
/* sio_tryread(fd serial device handler, pointer to data buffer, max length) -> byte count received */
u32_t bytes_count_received = sio_tryread(priv->sd, &c, 1);
while ( bytes_count_received > 0)
{ /* Push Bytes into */
slipif_rxbyte_input(netif, c); /* slipif_rxbyte_input(network interface, received character) */
}
}
In ./network/slip/slip_sio.c it shows that we slip uart has receive buffer of 512b
static uint8_t recv_buffer[512];
static bool wait = false;
static uart_config_t slip_uart = {
.baud = BAUD_RATE,
.recv_buffer = { .s_elem = 1, .n_elem = sizeof(recv_buffer), .buffer = recv_buffer }
};
sio_tryread() --> slipif_poll() --> "char" --> slipif_rxbyte_input(,char) --> "char" --> slipif_rxbyte(,char) --> Pointer to full packet (NULL if not yet) --> to netif->input()
called by slipif_rxbyte_input()
We can try adding a buffer at slipif_poll(), but the issue is that we still have the delay of the main loop. A combination of:
Increasing the ring buffer at the uart layer (./utils/uart.c) (But it seems pretty high already...)
Copying as much in slipif_poll() and push into the slip stream. (instead of single byte, copy like say 50 bytes) (./thirdparty/lwip/src/netif/slipif.c)
Or we can make the ISR call slipif polling if dangerously too close to the ring buffer limit.
/* Testing current state alarm
********************************/
{ // Verification
uint8_t old_payload[] = {0x9f, 0x18, 0x7b, 0x01, 0x19, 0x02, 0x9a, 0x01, 0xff};
uint8_t new_payload[] = {0x84, 0x18, 0x7b, 0x01, 0x19, 0x02, 0x9a, 0x01};
}
/* Testing for timestamp overflow using current state alarm scenario
**********************************************************************/
{ // Verification
char old_payload[] = {0x9f, 0x18, 0x7b, 0x01, 0x1a, 0x58, 0xbc, 0xeb, 0x11, 0x01, 0xff};
char new_payload[] = {0x84, 0x18, 0x7b, 0x01, 0x1a, 0x58, 0xbc, 0xeb, 0x11, 0x01};
}
/* Alarm state change log scenario
*************************************************************************/
{ // Verification
char old_payload[] = {
0x9f, 0x18, 0x7b, 0x02, 0x9f, 0x9f, 0x1a, 0x58, 0xbc,
0xeb, 0x0f, 0x00, 0x01, 0xff, 0x9f, 0x1a, 0x58, 0xbc,
0xeb, 0x10, 0x18, 0xc8, 0x01, 0xff, 0x9f, 0x1a, 0x58,
0xbc, 0xeb, 0x11, 0x19, 0x01, 0x90, 0x01, 0xff, 0xff,
0xff
};
char new_payload[] = {
0x83, 0x18, 0x7b, 0x02, 0x83, 0x82, 0x1a, 0x58, 0xbc,
0xeb, 0x0f, 0x00, 0x82, 0x1a, 0x58, 0xbc, 0xeb, 0x10,
0x18, 0xc8, 0x82, 0x1a, 0x58, 0xbc, 0xeb, 0x11, 0x19,
0x01, 0x90
};
}
/* Event log scenario
*************************************************************************/
{ // Verification
char old_payload[] = {
0x9f, 0x18, 0x7b, 0x03, 0x9f, 0x9f, 0x1a, 0x58, 0xbc,
0xeb, 0x0f, 0x00, 0x01, 0xff, 0x9f, 0x1a, 0x58, 0xbc,
0xeb, 0x10, 0x18, 0xc8, 0x01, 0xff, 0x9f, 0x1a, 0x58,
0xbc, 0xeb, 0x11, 0x19, 0x01, 0x90, 0x01, 0xff, 0xff,
0xff
};
char new_payload[] = {
0x83, 0x18, 0x7b, 0x03, 0x83, 0x82, 0x1a, 0x58, 0xbc,
0xeb, 0x0f, 0x00, 0x82, 0x1a, 0x58, 0xbc, 0xeb, 0x10,
0x18, 0xc8, 0x82, 0x1a, 0x58, 0xbc, 0xeb, 0x11, 0x19,
0x01, 0x90
};
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.