Skip to content

Commit

Permalink
[sdk] matter restructure part 2
Browse files Browse the repository at this point in the history
* Isolate matter solution from default sdk
* Synchronize code between amebaZ2 and amebaD to create a single matter repo
* Remove bt_matter_adapter and use ble_matter_adapter on default
* Remove mbedtls-2.28.1 and move to matter repo
* Move matter related tools (including toolchain) to matter repo
* Add submodule for matter repo
  • Loading branch information
xshuqun committed Aug 8, 2024
1 parent 61306c6 commit 6f682bb
Show file tree
Hide file tree
Showing 450 changed files with 3,483 additions and 225,462 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: build ameba matter

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
Expand All @@ -31,13 +31,21 @@ jobs:
ref: master
submodules: recursive
path: connectedhomeip

- name: checkout ambd_matter main branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
path: ambd_matter


- name: checkout ameba-rtos-matter main branch
uses: actions/checkout@v3
with:
repository: Ameba-AIoT/ameba-rtos-matter
ref: main
submodules: recursive
path: ambd_matter/component/common/application/matter

- name: Build all-clusters-app
run: |
echo "Setting up build environment"
Expand All @@ -53,7 +61,7 @@ jobs:
make all
echo "Build all-clusters-app completed"
make clean
- name: Build lighting-app
run: |
echo "Setting up build environment"
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "matter"]
path = component/common/application/matter
url = https://github.com/Ameba-AIoT/ameba-rtos-matter.git
branch = main
20 changes: 10 additions & 10 deletions MATTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The only solution is to add Ameba's all-clusters-app.zap.

In `component/common/application/matter/project/amebad/Makefile`, the default all-clusters-app.zap in connectedhomeip will be replaced by Ameba's all-clusters-app.zap

@cp $(MATTER_DIR)/example/chiptest/all-clusters-app.zap $(ALL_CLUSTERS_ZAP)
@cp $(MATTER_DIR)/example/chiptest/all-clusters-app.zap $(ALL_CLUSTERS_ZAP)

## Get Ameba SDK & Matter SDK

Expand All @@ -23,12 +23,12 @@ In `component/common/application/matter/project/amebad/Makefile`, the default al
Create a common directory for Ameba and Matter SDK

mkdir dev

cd dev

To check out this repository:

git clone https://github.com/ambiot/ambd_matter.git
git clone --recurse-submodules https://github.com/ambiot/ambd_matter.git

To check out Matter repository:

Expand All @@ -37,36 +37,36 @@ To check out Matter repository:
Make sure ambz2_matter and connectedhomeip are on the same directory level

dev/
├── ambd_matter
└── connectedhomeip
├── ambd_matter
└── connectedhomeip

## Set Matter Build Environment

> Follow below guide to install prerequisites
> https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md

cd connectedhomeip

git submodule sync

git submodule update --init --recursive

source scripts/bootstrap.sh

source scripts/activate.sh

## Make project_lp

cd ambd_matter/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/

make all

## Make Matter Libraries

cd ambd_matter/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/

make -C asdk all_clusters

## Make project_hp

in the same project_hp directory,
Expand Down
15 changes: 8 additions & 7 deletions component/common/api/at_cmd/atcmd_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,9 @@ void fATWx(void *arg){
#if CONFIG_LWIP_LAYER
u8 *mac = LwIP_GetMAC(&xnetif[0]);
u8 *ip = LwIP_GetIP(&xnetif[0]);
#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
u8 *ipv6_0 = LwIP_GetIPv6_linklocal(&xnetif[0]);
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
u8 *ipv6_1 = LwIP_GetIPv6_global(&xnetif[0]);
#endif
#endif
Expand All @@ -556,9 +556,9 @@ void fATWx(void *arg){
#if CONFIG_LWIP_LAYER
mac = LwIP_GetMAC(&xnetif[i]);
ip = LwIP_GetIP(&xnetif[i]);
#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
ipv6_0 = LwIP_GetIPv6_linklocal(&xnetif[i]);
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
ipv6_1 = LwIP_GetIPv6_global(&xnetif[i]);
#endif
#endif
Expand Down Expand Up @@ -589,18 +589,19 @@ void fATWx(void *arg){
printf("\n\r==============================");
printf("\n\r\tMAC => %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]) ;
printf("\n\r\tIP => %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
printf("\n\r\tGW => %d.%d.%d.%d\n\r", gw[0], gw[1], gw[2], gw[3]);
printf("\n\r\tmsk => %d.%d.%d.%d\n\r", msk[0], msk[1], msk[2], msk[3]);

#if LWIP_IPV6
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
printf("\n\r\tLink-local IPV6 => %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
ipv6_0[0], ipv6_0[1], ipv6_0[2], ipv6_0[3], ipv6_0[4], ipv6_0[5], ipv6_0[6], ipv6_0[7],
ipv6_0[8], ipv6_0[9], ipv6_0[10], ipv6_0[11], ipv6_0[12], ipv6_0[13], ipv6_0[14], ipv6_0[15]);
printf("\n\r\tIPV6 => %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
printf("\n\r\tIPV6 => %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n\r",
ipv6_1[0], ipv6_1[1], ipv6_1[2], ipv6_1[3], ipv6_1[4], ipv6_1[5], ipv6_1[6], ipv6_1[7],
ipv6_1[8], ipv6_1[9], ipv6_1[10], ipv6_1[11], ipv6_1[12], ipv6_1[13], ipv6_1[14], ipv6_1[15]);
#endif
#endif
printf("\n\r\tGW => %d.%d.%d.%d\n\r", gw[0], gw[1], gw[2], gw[3]);
printf("\n\r\tmsk => %d.%d.%d.%d\n\r", msk[0], msk[1], msk[2], msk[3]);
#endif
if(setting.mode == RTW_MODE_AP || i == 1)
{
Expand Down Expand Up @@ -1217,8 +1218,8 @@ void fATWC(void *arg){
#if CONFIG_LWIP_LAYER
/* Start DHCPClient */
LwIP_DHCP(0, DHCP_START);
#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
LwIP_DHCP6(0, DHCP6_START);
#endif
#endif
Expand Down
117 changes: 50 additions & 67 deletions component/common/api/lwip_netconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "wlan_fast_connect/example_wlan_fast_connect.h"
#endif

#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
#include "lwip/dhcp6.h"
#include "lwip/prot/dhcp6.h"
#endif
Expand Down Expand Up @@ -101,8 +101,8 @@

/* Private define ------------------------------------------------------------*/
#define MAX_DHCP_TRIES 5
#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
#define MAX_DHCP6_TRIES 5
#endif
#endif
Expand Down Expand Up @@ -298,12 +298,6 @@ extern u8 is_the_same_ap;

#endif

#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6 && (LWIP_IPV6_DHCP6_STATEFUL||LWIP_IPV6_DHCP6_STATELESS)
extern err_t dhcp6_enable(struct netif *netif);
#endif
#endif

/**
* @brief LwIP_DHCP_Process_Handle
* @param None
Expand Down Expand Up @@ -573,48 +567,9 @@ uint8_t LwIP_DHCP(uint8_t idx, uint8_t dhcp_state)
}
}

void LwIP_ReleaseIP(uint8_t idx)
{
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
struct netif *pnetif = &xnetif[idx];
#if LWIP_VERSION_MAJOR >= 2
IP4_ADDR(ip_2_ip4(&ipaddr), 0, 0, 0, 0);
IP4_ADDR(ip_2_ip4(&netmask), 255, 255 , 255, 0);
IP4_ADDR(ip_2_ip4(&gw), 0, 0, 0, 0);
netif_set_addr(pnetif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask),ip_2_ip4(&gw));
#else
IP4_ADDR(&ipaddr, 0, 0, 0, 0);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 0, 0, 0, 0);

netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
#endif

#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
IP6_ADDR(ip_2_ip6(&ipaddr), 0,0,0,0);
for (int idx = 1; idx < LWIP_IPV6_NUM_ADDRESSES; idx++) {
netif_ip6_addr_set_state(pnetif, idx, IP6_ADDR_INVALID);
netif_ip6_addr_set(pnetif, idx, ip_2_ip6(&ipaddr));
}
#endif
#endif
}

uint8_t* LwIP_GetMAC(struct netif *pnetif)
{
return (uint8_t *) (pnetif->hwaddr);
}

uint8_t* LwIP_GetIP(struct netif *pnetif)
{
return (uint8_t *) &(pnetif->ip_addr);
}

#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 1
#if LWIP_IPV6
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
extern err_t dhcp6_enable(struct netif *netif);
uint8_t LwIP_DHCP6(uint8_t idx, uint8_t dhcp6_state)
{
struct ip_addr ipaddr;
Expand Down Expand Up @@ -717,6 +672,7 @@ uint8_t LwIP_DHCP6(uint8_t idx, uint8_t dhcp6_state)
{
/* DHCP timeout */
if (dhcp6->tries > MAX_DHCP6_TRIES || pnetif->rs_timeout)

{
DHCP6_state = DHCP6_TIMEOUT;
/* Stop DHCP */
Expand Down Expand Up @@ -757,18 +713,47 @@ uint8_t LwIP_DHCP6(uint8_t idx, uint8_t dhcp6_state)
vTaskDelay(30);
}
}
#endif
#endif
void LwIP_ReleaseIP(uint8_t idx)
{
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
struct netif *pnetif = &xnetif[idx];
#if LWIP_VERSION_MAJOR >= 2
IP4_ADDR(ip_2_ip4(&ipaddr), 0, 0, 0, 0);
IP4_ADDR(ip_2_ip4(&netmask), 255, 255 , 255, 0);
IP4_ADDR(ip_2_ip4(&gw), 0, 0, 0, 0);
netif_set_addr(pnetif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask),ip_2_ip4(&gw));
#else
IP4_ADDR(&ipaddr, 0, 0, 0, 0);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 0, 0, 0, 0);

netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
#endif

uint8_t* LwIP_GetIPv6_linklocal(struct netif *pnetif)
#if LWIP_IPV6
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
IP6_ADDR(ip_2_ip6(&ipaddr), 0,0,0,0);
for (int idx = 1; idx < LWIP_IPV6_NUM_ADDRESSES; idx++) {
netif_ip6_addr_set_state(pnetif, idx, IP6_ADDR_INVALID);
netif_ip6_addr_set(pnetif, idx, ip_2_ip6(&ipaddr));
}
#endif
#endif
}

uint8_t* LwIP_GetMAC(struct netif *pnetif)
{
return (uint8_t *) netif_ip6_addr(pnetif, 0)->addr;
return (uint8_t *) (pnetif->hwaddr);
}

uint8_t* LwIP_GetIPv6_global(struct netif *pnetif)
uint8_t* LwIP_GetIP(struct netif *pnetif)
{
return (uint8_t *) netif_ip6_addr(pnetif, 1)->addr;
return (uint8_t *) &(pnetif->ip_addr);
}
#endif
#endif

uint8_t* LwIP_GetGW(struct netif *pnetif)
{
Expand Down Expand Up @@ -913,20 +898,18 @@ void LwIP_AUTOIP(struct netif *pnetif)
}
}
#endif

#if LWIP_IPV6
/* Get IPv6 address with lwip 1.5.0 */
void LwIP_AUTOIP_IPv6(struct netif *pnetif)
uint8_t* LwIP_GetIPv6_linklocal(struct netif *pnetif)
{
#if LWIP_VERSION_MAJOR >= 2
uint8_t *ipv6 = (uint8_t *) netif_ip6_addr(pnetif, 0)->addr;
#else
uint8_t *ipv6 = (uint8_t *) &(pnetif->ip6_addr[0].addr[0]);
#endif
netif_create_ip6_linklocal_address(pnetif, 1);
printf("\nIPv6 link-local address: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
ipv6[0], ipv6[1], ipv6[2], ipv6[3], ipv6[4], ipv6[5], ipv6[6], ipv6[7],
ipv6[8], ipv6[9], ipv6[10], ipv6[11], ipv6[12], ipv6[13], ipv6[14], ipv6[15]);
return (uint8_t *) netif_ip6_addr(pnetif, 0)->addr;
}
#if LWIP_IPV6_DHCP6 && (LWIP_VERSION_MAJOR >= 2) && (LWIP_VERSION_MINOR >= 1)
uint8_t* LwIP_GetIPv6_global(struct netif *pnetif)
{
return (uint8_t *) netif_ip6_addr(pnetif, 1)->addr;
}
#endif
#endif

uint32_t LWIP_Get_Dynamic_Sleep_Interval()
Expand All @@ -936,4 +919,4 @@ uint32_t LWIP_Get_Dynamic_Sleep_Interval()
#else
return 0;
#endif
}
}
Loading

0 comments on commit 6f682bb

Please sign in to comment.