Showing posts with label Thread Protocol. Show all posts
Showing posts with label Thread Protocol. Show all posts

Friday, October 28, 2022

Build and run Matter and OpenThread lighting-app on EFR32MG24 to work with Apple HomePod Mini and iPhone Home App.

The following steps show you how to build and run Matter and OpenThread lighting-app on EFR32MG24 to work with Apple HomePod Mini and iPhone Home App.

1. Refer to steps 1 and 2 in How to setup and build Matter/CHIP EFR32 Lighting Example on Ubuntu 20.04 to setup Ubuntu 20.04 build environment and git master Matter source codes.

2. Switch to v1.0-branch and workable commit.

    cd connectedhomeip/
    git fetch origin
    git branch -a
    git checkout -b v1.0 remotes/origin/v1.0-branch
    git submodule update --init --recursive
    git checkout 561d23d0db215a99705ff0696e73853c8edf11b2
 

3. Build lighting-app for BRD4186C

    ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app BRD4186C

4. Download chip-efr32-lighting-example.hex (can be found under out/lighting-app/BRD4186C) in to BRD4186C+BRD4001A.

5. Make sure your Apple HomePod Mini and iPhone are update to OS 16.1.

6. Start Home App on your iPhone and scan the QR code on LCD of BRD4186C+BRD4001A. Following Home App wizard to complete settings.


7. You can have the Matter enable Light connecting with HomePod Mini and control it with iPhone Home App.

P.S. You can add the following code into AppTask::Init() in AppTask.c to print URL on RTT viewer output to generate QR code on browser.

PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));

P.S. You can use the following command to build lock-app SED for low power device test.

./scripts/examples/gn_efr32_example.sh ./examples/lock-app/efr32/ ./out/lock-app_SED BRD4186C --sed "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false is_debug=false show_qr_code=true chip_build_libshell=false disable_lcd=false enable_openthread_cli=false"

Tuesday, August 25, 2020

Build OpenThread Sleepy End Device doorlock prototype to test with Rasperry Pi OpenThread Border Router

The following steps show how to build OpenThread Sleepy End Device doorlock prototype to test with Rasperry Pi OpenThread Border Router

1. Build OpenThread Sleepy End Device doorlock prototype for TI LAUNCHXL-CC26X2R1

1.1 Download/Install TI CCS 10.1 and SIMPLELINK-CC13X2-26X2-SDK v4.20.00.35.

1.2 Import thread door_lock example from C:\ti\simplelink_cc13x2_26x2_sdk_4_20_00_35\examples\rtos\CC26X2R1_LAUNCHXL\thread\door_lock

1.3 Set door_lock as Sleepy End Device from sysconfig.

 

1.4 Add the following codes in tiop_ui.c for providing API to output IPv6 address to UART console.

inline uint16_t Swap16(uint16_t v)
{
    return (((v & 0x00ffU) << 8) & 0xff00) | (((v & 0xff00U) >> 8) & 0x00ff);
}
 

inline uint16_t HostSwap16(uint16_t v)
{
    return Swap16(v);
}

void tiopCUIOutputIp6Address(otIp6Address aAddress)
{
    CUI_statusLinePrintf(
        clientHandle, nwkInfoLine1,
        "[" CUI_COLOR_GREEN "IPv6" CUI_COLOR_RESET "] %s - %x:%x:%x:%x:%x:%x:%x:%x",
        "Addr",
        HostSwap16(aAddress.mFields.m16[0]), HostSwap16(aAddress.mFields.m16[1]),
                HostSwap16(aAddress.mFields.m16[2]), HostSwap16(aAddress.mFields.m16[3]), HostSwap16(aAddress.mFields.m16[4]),
                HostSwap16(aAddress.mFields.m16[5]), HostSwap16(aAddress.mFields.m16[6]), HostSwap16(aAddress.mFields.m16[7]));
}

1.5 Add the following line to expose API tiopCUIOutputIp6Address in tiop_ui.h.

extern void tiopCUIOutputIp6Address(otIp6Address aAddress);

1.6 Add the following line in "case DoorLock_evtKeyRight:..." of processEvent (doorlock.c) to output IPv6 address when right button is pressed.

tiopCUIOutputIp6Address(*(otThreadGetRloc(OtInstance_get())));

1.7 Build and download sleepy door_lock firmware into LAUNCHXL-CC26X2R1.

 

2. Setup OpenThread Border Router and libcoap on Raspberry Pi.

2.1 Refer to this link to setup OpenThread Border Router on Raspberry Pi.

2.2 Run the following command in Raspberry Pi console to setup libcoap.

      sudo apt install autoconf automake libtool
      git clone --depth 1 --recursive -b dtls https://github.com/home-assistant/libcoap.git
      cd libcoap
      ./autogen.sh
      ./configure --disable-documentation --disable-shared --without-debug CFLAGS="-D COAP_DEBUG_FD=stderr"
      make
      sudo make install

3. Use the following commands on Raspberry Pi console and start sleepy door_lock to join thread network. Then, press right button on LAUNCHXL-CC26X2R1 to print IPv6 address of sleepy door_lock.

sudo ot-ctl commissioner start
sudo ot-ctl commissioner joiner add 00124b001ca16238 DRRLCK1

4. Use the following command to request lock state of sleepy door_lock from border router.

coap-client -m get coap://[fd11:1111:1122:0:0:ff:fe00:ec08]/doorlock/lockstate

5. Use the following command to change lock state of sleepy door_lock from border router.

coap-client -m post coap://[fd11:1111:1122:0:0:ff:fe00:ec08]/doorlock/lockstate -e unlock

 


Friday, August 21, 2020

Running OpenThread Border Router and device with Raspberry Pi and Silicon Labs EFR32 Kits

Silicon Labs releases Simplicity Studio v5 which supports OpenThread in the end of July 2020. To run the whole thing, you will need one Raspberry Pi, one SLWSTK6000B (BRD4001A+BRD4161A to act as OpenThread RCP connecting to OpenThread Border Router running on Raspberry Pi), and one SLWSTK6006A (BRD4001A+BRD4180A to act as OpenThread device to join Thread network). 


 

In the following steps, I will show you how to run OpenThread Border Router and device with Raspberry Pi and Silicon Labs EFR32 Kits.

 

1. Create and build OpenThread RCP to run on SLWSTK6000B .

1.1 Start  Simplicity Studio v5 and select ot-rcp project from EXAMPLE PROJECTS on Laucher

1.2 Switch to Simplicity IDE tab and open ot-rcp.slcp. Click "Force Generation" to generate codes and click "Build" button to build the project.

1.3 Download ot-rcp.s37 to SLWSTK6000B .


2. Setup OpenThread Border Router on Raspberry Pi.

2.1 Download Raspbian Stretch Lite OS image and put it on SD card. Insert the SD card into Raspberry Pi and power on it. Enable ssh access on Raspberry Pi and remote login with TeraTerm.

2.2 Run the following command to get OpenThread Border Router project (I use commit a69a9d5c82d25b6d3c6ddd5ac29d80676b34465f in my test).

      sudo apt-get update

      sudo apt-get install -y git

      git clone https://github.com/openthread/ot-br-posix

      cd ot-br-posix

      git checkout 28991cdf9f3c8794ccfa5843685228e8d93470a7

      git submodule update --init --recursive

2.3 Build and install OpenThread Border Router

      ./script/bootstrap

      ./script/setup

2.4 Connect SLWSTK6000B running OpenThread RCP to Raspberry PI by USB cable and make sure SLWSTK6000B simulates ttyACM0 under /dev.

2.5 Reboot OpenThread Border Router

      sudo reboot

2.6 After reboot, you can start a browser and use http://ip-of-raspberry-pi-border-router to access to web page of OpenThread Border Router.

 

2.7 Switch to Form tab and click "FORM" button to form a Thread Network.


3. Create and build OpenThread Cli-FTD to run on SLWSTK6006A .

3.1 Start  Simplicity Studio v5 and select ot-cli-ftd project from EXAMPLE PROJECTS on Laucher

 

3.2 Switch to Simplicity IDE tab and open ot-cli-ftd.slcp. Click "Force Generation" to generate codes and click "Build" button to build the project.

3.3 Download ot-cli-ftd.s37 to SLWSTK6006A .


4. Commission ot-cli-ftd running on SLWSTK6006A to Openthread Border Router.

4.1 Run commissioner and add device eui64/PSK to commissioner on Raspberry Pi console.

      sudo ot-ctl commissioner start

      sudo ot-ctl commissioner joiner add 000d6ffffe0a457b J01NME

4.2 Start ot-cli-ftd and run joiner with PSK to join OpenThread network.

      ifconfig up
      joiner start J01NME

      thread start


4.3 Try to ping ot-cli-ftd from OpenThread Border Router to make sure device joins.

 

4.4 Test the connectivity between the Joiner device in the Thread network and the external internet by pinging a public IPv4 address, such as 64:ff9b::808:808 (the Well-Known Prefix of 64:ff9b::/96 and an IPv4 address of 8.8.8.8 (Google Public DNS) combine to form an IPv6 address of 64:ff9b::808:808). Remember to do "thread start" before you do "ping 64:ff9b::808:808"


Saturday, July 23, 2016

Run OpenThread on CC2538DK

Since Thread Protocol is discussed more and more recently and we see open source OpenThread is release, I try to test OpenThread.The following steps shows you how to run OpenThread on CC2538DK

To save your time to setup GCC for building this example, you can use InstantContiki 3.0 running on VMPlayer.

1. git clone --recursive https://github.com/openthread/openthread
2. cd openthread
3. run "./bootstrap"
4. do "make -f examples/Makefile-cc2538" and you will get arm-none-eabi-ot-cli.bin under /output/bin
5. Download arm-none-eabi-ot-cli.bin to two CC2538DK using Flash Programmer 2.
6. On one of CC2538DK, you can run Cli command "start" to create OpenThread network
   > start
   start
   Done
   > state
   state
   leader
   Done

7.  On another CC2538DK, you can run Cli command "start" to start OpenThread router when there is a OpenThread network existed.
   > start
   start
   Done
   > state
   router
   Done
 
8. On leader node, you can use "scan" to see get the router node and use "ping" to ping the router.
 9. On router node, you can use "scan" to see get the leader node and use "ping" to ping the leader.