Giter VIP home page Giter VIP logo

sew-lwm2m-reference-design's People

Contributors

mofosyne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sew-lwm2m-reference-design's Issues

log read char in failed

Clue:

  • This should show something... but it doesnt
__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

Wiring Issues

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?

Event and alarm payload buffer size declaration.

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);

Fix unit test vectors for Delivery Schedule

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.

Convert Interval data base payload to use definite array markers

{ /* 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 
                    };
}

prv_parseNumber() has integer overflow in result

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;
}
  • ~/git/sew-lwm2m-reference-design/thirdparty/wakaama/core/uri.c

During bootup there is `failed to register confirmable resource since the object is not registered` in log

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] --------------------------

Concept: Self test memory and range check

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.

Test setup instructions and correct as required

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.

Add wiring diagram to README.md

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.

Need to support multiple packets in a slip polling loop

/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.

Add unit tests for data delivery base

  • Test adding handlers
  • Test removing handlers
  • Test sample handler function with different user_data points
  • Test the process_scheule funciton calls the registered handlers (only).

Convert Event And Alarm to use definite cbor array markup


  /*  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
                      };
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.