mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-21 10:25:54 +08:00
更新硬件SDK
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# 说明
|
||||
|
||||
* 此demo是云喇叭演示demo
|
||||
|
||||
## 功能说明
|
||||
1:设备启动后首先播报:“正在开机”
|
||||
2:设备连接mqtt服务器并订阅主题成功后,会播报:“服务器连接成功”
|
||||
3:用另一个mqtt clinet向设备订阅的主题发送固定格式的报文,设备则会播报支付宝收款xxxx元
|
||||
|
||||
## 设备订阅的主题
|
||||
/sub/topic/money/{imei} {imei}为模块的imei
|
||||
如模块的imei为:866714xxxx16190
|
||||
|
||||
则设备订阅的主题为/sub/topic/money/866714xxxx16190
|
||||
|
||||
## 设备连接的服务器
|
||||
host:lbsmqtt.airm2m.com
|
||||
port:1884
|
||||
|
||||
## 报文下发格式
|
||||
{"money":"number"}
|
||||
其中number为一个不大于99999999.99的数字
|
||||
|
||||
如:
|
||||
向主题“/sub/topic/money/866714xxxx16190”下发{"money":"12345678.9"}
|
||||
设备则会播报 “支付宝收款一千两百三十四万五千六百七十八点九元”
|
||||
@@ -0,0 +1,350 @@
|
||||
#ifndef __RTE_DEVICE_H
|
||||
#define __RTE_DEVICE_H
|
||||
|
||||
#include "ec618.h"
|
||||
|
||||
/* Peripheral IO Mode Select, Must Configure First !!!
|
||||
Note, when receiver works in DMA_MODE, interrupt is also enabled to transfer tailing bytes.
|
||||
*/
|
||||
|
||||
#define POLLING_MODE 0x1
|
||||
#define DMA_MODE 0x2
|
||||
#define IRQ_MODE 0x3
|
||||
#define UNILOG_MODE 0x4
|
||||
|
||||
#define RTE_UART0_TX_IO_MODE UNILOG_MODE
|
||||
#define RTE_UART0_RX_IO_MODE IRQ_MODE
|
||||
#define USART0_RX_TRIG_LVL (30)
|
||||
|
||||
#define RTE_UART1_TX_IO_MODE DMA_MODE
|
||||
#define RTE_UART1_RX_IO_MODE DMA_MODE
|
||||
|
||||
#define RTE_UART2_TX_IO_MODE POLLING_MODE
|
||||
#define RTE_UART2_RX_IO_MODE DMA_MODE
|
||||
|
||||
#define RTE_SPI0_IO_MODE POLLING_MODE
|
||||
|
||||
#define RTE_SPI1_IO_MODE POLLING_MODE
|
||||
|
||||
#define RTE_I2C0_IO_MODE POLLING_MODE
|
||||
#define RTE_I2C1_IO_MODE POLLING_MODE
|
||||
|
||||
|
||||
// I2C0 (Inter-integrated Circuit Interface) [Driver_I2C0]
|
||||
// Configuration settings for Driver_I2C0 in component ::Drivers:I2C
|
||||
#define RTE_I2C0 1
|
||||
|
||||
// { PAD_PIN28}, // 0 : gpio13 / 2 : I2C0 SCL
|
||||
// { PAD_PIN27}, // 0 : gpio12 / 2 : I2C0 SDA
|
||||
#define RTE_I2C0_SCL_BIT 28 // AUDIO use 28
|
||||
#define RTE_I2C0_SCL_FUNC PAD_MUX_ALT2
|
||||
|
||||
#define RTE_I2C0_SDA_BIT 27 // AUDIO use 27
|
||||
#define RTE_I2C0_SDA_FUNC PAD_MUX_ALT2
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_I2C0_DMA_TX_EN 0
|
||||
#define RTE_I2C0_DMA_TX_REQID DMA_REQUEST_I2C0_TX
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_I2C0_DMA_RX_EN 0
|
||||
#define RTE_I2C0_DMA_RX_REQID DMA_REQUEST_I2C0_RX
|
||||
|
||||
// I2C1 (Inter-integrated Circuit Interface) [Driver_I2C1]
|
||||
// Configuration settings for Driver_I2C1 in component ::Drivers:I2C
|
||||
#define RTE_I2C1 1
|
||||
|
||||
// { PAD_PIN20}, // 0 : gpio5 / 2 : I2C1 SCL
|
||||
// { PAD_PIN19}, // 0 : gpio4 / 2 : I2C1 SDA
|
||||
#define RTE_I2C1_SCL_BIT 20
|
||||
#define RTE_I2C1_SCL_FUNC PAD_MUX_ALT2
|
||||
|
||||
#define RTE_I2C1_SDA_BIT 19
|
||||
#define RTE_I2C1_SDA_FUNC PAD_MUX_ALT2
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_I2C1_DMA_TX_EN 1
|
||||
#define RTE_I2C1_DMA_TX_REQID DMA_REQUEST_I2C1_TX
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_I2C1_DMA_RX_EN 1
|
||||
#define RTE_I2C1_DMA_RX_REQID DMA_REQUEST_I2C1_RX
|
||||
|
||||
|
||||
// UART0 (Universal asynchronous receiver transmitter) [Driver_USART0]
|
||||
// Configuration settings for Driver_USART0 in component ::Drivers:USART
|
||||
#define RTE_UART0_CTS_PIN_EN 0
|
||||
#define RTE_UART0_RTS_PIN_EN 0
|
||||
|
||||
// { PAD_PIN27}, // 0 : gpio12 / 3 : UART0 RTSn
|
||||
// { PAD_PIN28}, // 0 : gpio13 / 3 : UART0 CTSn
|
||||
// { PAD_PIN29}, // 0 : gpio14 / 3 : UART0 RXD
|
||||
// { PAD_PIN30}, // 0 : gpio15 / 3 : UART0 TXD
|
||||
#define RTE_UART0_RTS_BIT 27
|
||||
#define RTE_UART0_RTS_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_UART0_CTS_BIT 28
|
||||
#define RTE_UART0_CTS_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_UART0_RX_BIT 29
|
||||
#define RTE_UART0_RX_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_UART0_TX_BIT 30
|
||||
#define RTE_UART0_TX_FUNC PAD_MUX_ALT3
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_UART0_DMA_TX_REQID DMA_REQUEST_USART0_TX
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_UART0_DMA_RX_REQID DMA_REQUEST_USART0_RX
|
||||
|
||||
// UART1 (Universal asynchronous receiver transmitter) [Driver_USART1]
|
||||
// Configuration settings for Driver_USART1 in component ::Drivers:USART
|
||||
#define RTE_UART1_CTS_PIN_EN 1
|
||||
#define RTE_UART1_RTS_PIN_EN 1
|
||||
|
||||
// { PAD_PIN31}, // 0 : gpio16 / 1 : UART1 RTS
|
||||
// { PAD_PIN32}, // 0 : gpio17 / 1 : UART1 CTS
|
||||
// { PAD_PIN33}, // 0 : gpio18 / 1 : UART1 RXD
|
||||
// { PAD_PIN34}, // 0 : gpio19 / 1 : UART1 TXD
|
||||
#define RTE_UART1_RTS_BIT 31
|
||||
#define RTE_UART1_RTS_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_UART1_CTS_BIT 32
|
||||
#define RTE_UART1_CTS_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_UART1_RX_BIT 33
|
||||
#define RTE_UART1_RX_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_UART1_TX_BIT 34
|
||||
#define RTE_UART1_TX_FUNC PAD_MUX_ALT1
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_UART1_DMA_TX_REQID DMA_REQUEST_USART1_TX
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_UART1_DMA_RX_REQID DMA_REQUEST_USART1_RX
|
||||
|
||||
// UART2 (Universal asynchronous receiver transmitter) [Driver_USART2]
|
||||
// Configuration settings for Driver_USART2 in component ::Drivers:USART
|
||||
#define RTE_UART2_CTS_PIN_EN 0
|
||||
#define RTE_UART2_RTS_PIN_EN 0
|
||||
|
||||
// { PAD_PIN25}, // 0 : gpio10 / 3 : UART2 RXD
|
||||
// { PAD_PIN26}, // 0 : gpio11 / 3 : UART2 TXD
|
||||
#define RTE_UART2_RX_BIT 25
|
||||
#define RTE_UART2_RX_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_UART2_TX_BIT 26
|
||||
#define RTE_UART2_TX_FUNC PAD_MUX_ALT3
|
||||
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_UART2_DMA_TX_REQID DMA_REQUEST_USART2_TX
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_UART2_DMA_RX_REQID DMA_REQUEST_USART2_RX
|
||||
|
||||
// SPI0 (Serial Peripheral Interface) [Driver_SPI0]
|
||||
// Configuration settings for Driver_SPI0 in component ::Drivers:SPI
|
||||
#define RTE_SPI0 1
|
||||
|
||||
// { PAD_PIN21}, // 0 : gpio16 / 1 : UART1 RTS / 2 : SPI0 SSn
|
||||
// { PAD_PIN22}, // 0 : gpio11 / 1 : UART1 CTS / 2 : SPI0 MOSI
|
||||
// { PAD_PIN23}, // 0 : gpio14 / 1 : UART1 RXD / 2 : SPI0 MISO
|
||||
// { PAD_PIN24}, // 0 : gpio15 / 1 : UART1 TXD / 2 : SPI0 SCLK
|
||||
#define RTE_SPI0_SSN_BIT 21
|
||||
#define RTE_SPI0_SSN_FUNC PAD_MUX_ALT2
|
||||
|
||||
#define RTE_SPI0_MOSI_BIT 22
|
||||
#define RTE_SPI0_MOSI_FUNC PAD_MUX_ALT2
|
||||
|
||||
#define RTE_SPI0_MISO_BIT 23
|
||||
#define RTE_SPI0_MISO_FUNC PAD_MUX_ALT2
|
||||
|
||||
#define RTE_SPI0_SCLK_BIT 24
|
||||
#define RTE_SPI0_SCLK_FUNC PAD_MUX_ALT2
|
||||
|
||||
#define RTE_SPI0_SSN_GPIO_INSTANCE 1
|
||||
#define RTE_SPI0_SSN_GPIO_INDEX 0
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_SPI0_DMA_TX_REQID DMA_REQUEST_SPI0_TX
|
||||
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_SPI0_DMA_RX_REQID DMA_REQUEST_SPI0_RX
|
||||
|
||||
// SPI1 (Serial Peripheral Interface) [Driver_SPI1]
|
||||
// Configuration settings for Driver_SPI1 in component ::Drivers:SPI
|
||||
#define RTE_SPI1 1
|
||||
|
||||
// { PAD_PIN13}, // 0 : gpio2 / 1 : UART0 RTSn / 3 : SPI1 SSn
|
||||
// { PAD_PIN14}, // 0 : gpio3 / 1 : UART0 CTSn / 3 : SPI1 MOSI
|
||||
// { PAD_PIN15}, // 0 : gpio4 / 1 : UART0 RXD / 3 : SPI1 MISO
|
||||
// { PAD_PIN16}, // 0 : gpio5 / 1 : UART0 TXD / 3 : SPI1 SCLK
|
||||
#define RTE_SPI1_SSN_BIT 13
|
||||
#define RTE_SPI1_SSN_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_SPI1_MOSI_BIT 14
|
||||
#define RTE_SPI1_MOSI_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_SPI1_MISO_BIT 15
|
||||
#define RTE_SPI1_MISO_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_SPI1_SCLK_BIT 16
|
||||
#define RTE_SPI1_SCLK_FUNC PAD_MUX_ALT3
|
||||
|
||||
#define RTE_SPI1_SSN_GPIO_INSTANCE 0
|
||||
#define RTE_SPI1_SSN_GPIO_INDEX 2
|
||||
|
||||
// DMA
|
||||
// Tx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_SPI1_DMA_TX_REQID DMA_REQUEST_SPI1_TX
|
||||
|
||||
// Rx
|
||||
// Channel <0=>0 <1=>1 <2=>2 <3=>3 <4=>4 <5=>5 <6=>6 <7=>7
|
||||
#define RTE_SPI1_DMA_RX_REQID DMA_REQUEST_SPI1_RX
|
||||
|
||||
|
||||
// PWM0 Controller [Driver_PWM0]
|
||||
// Configuration settings for Driver_PWM0 in component ::Drivers:PWM
|
||||
#define RTE_PWM 1
|
||||
|
||||
#define EFUSE_INIT_MODE POLLING_MODE
|
||||
#define L2CTLS_INIT_MODE POLLING_MODE
|
||||
|
||||
#define FLASH_BARE_RW_MODE 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define RTE_UART0 1
|
||||
#define RTE_UART1 1
|
||||
#define RTE_UART2 1
|
||||
/* to enable external thermal */
|
||||
#define EXTERNAL_NTC_EXIST 0
|
||||
|
||||
|
||||
#if (RTE_UART1 == 1)
|
||||
#define UART1_DTR_PAD_INDEX 26 // GPIO11
|
||||
#define UART1_DTR_GPIO_INSTANCE 0
|
||||
#define UART1_DTR_GPIO_PIN 11
|
||||
|
||||
#define UART1_RI_PAD_INDEX 44 // AONIO 4 = GPIO24
|
||||
#define UART1_RI_GPIO_INSTANCE 1
|
||||
#define UART1_RI_GPIO_PIN 8
|
||||
#define UART1_RI_PWM_INSTANCE 1
|
||||
#define UART1_RI_PWM_CLK_ID FCLK_TIMER1
|
||||
#define UART1_RI_PWM_CLK_SEL FCLK_TIMER1_SEL_26M
|
||||
|
||||
#define UART1_DCD_PAD_INDEX 45 // AONIO 5 = GPIO25
|
||||
#define UART1_DCD_GPIO_INSTANCE 1
|
||||
#define UART1_DCD_GPIO_PIN 9
|
||||
#endif
|
||||
|
||||
#if (RTE_UART2 == 1)
|
||||
#define UART2_DTR_PAD_INDEX 25 // GPIO10
|
||||
#define UART2_DTR_GPIO_INSTANCE 0
|
||||
#define UART2_DTR_GPIO_PIN 10
|
||||
|
||||
#define UART2_RI_PAD_INDEX 43 // AONIO 3 = GPIO23
|
||||
#define UART2_RI_GPIO_INSTANCE 1
|
||||
#define UART2_RI_GPIO_PIN 7
|
||||
#define UART2_RI_PWM_INSTANCE 0
|
||||
#define UART2_RI_PWM_CLK_ID FCLK_TIMER0
|
||||
#define UART2_RI_PWM_CLK_SEL FCLK_TIMER0_SEL_26M
|
||||
|
||||
#define UART2_DCD_PAD_INDEX 47 // AONIO 7 = GPIO27
|
||||
#define UART2_DCD_GPIO_INSTANCE 1
|
||||
#define UART2_DCD_GPIO_PIN 11
|
||||
#endif
|
||||
|
||||
|
||||
#define NETLIGHT_PAD_INDEX 46 // AONIO 6 = GPIO26
|
||||
#define NETLIGHT_PAD_ALT_FUNC PAD_MUX_ALT5
|
||||
#define NETLIGHT_PWM_INSTANCE 3
|
||||
|
||||
//USIM1 OPTION1
|
||||
#define USIM1_URST_OP1_PAD_INDEX 19 // GPIO4
|
||||
#define USIM1_URST_OP1_GPIO_INSTANCE 0
|
||||
#define USIM1_URST_OP1_GPIO_PIN 4
|
||||
#define USIM1_UCLK_OP1_PAD_INDEX 20 // GPIO5
|
||||
#define USIM1_UCLK_OP1_GPIO_INSTANCE 0
|
||||
#define USIM1_UCLK_OP1_GPIO_PIN 5
|
||||
#define USIM1_UIO_OP1_PAD_INDEX 21 // GPIO6
|
||||
#define USIM1_UIO_OP1_GPIO_INSTANCE 0
|
||||
#define USIM1_UIO_OP1_GPIO_PIN 6
|
||||
|
||||
//USIM1 OPTION2
|
||||
#define USIM1_UIO_OP2_PAD_INDEX 27 // GPIO12
|
||||
#define USIM1_UIO_OP2_GPIO_INSTANCE 0
|
||||
#define USIM1_UIO_OP2_GPIO_PIN 12
|
||||
#define USIM1_URST_OP2_PAD_INDEX 28 // GPIO13
|
||||
#define USIM1_URST_OP2_GPIO_INSTANCE 0
|
||||
#define USIM1_URST_OP2_GPIO_PIN 13
|
||||
#define USIM1_UCLK_OP2_PAD_INDEX 29 // GPIO14
|
||||
#define USIM1_UCLK_OP2_GPIO_INSTANCE 0
|
||||
#define USIM1_UCLK_OP2_GPIO_PIN 14
|
||||
|
||||
//USIM1 clock latched by AONIO, for example, use AONIO-6 test on EVB
|
||||
#define AONIO_6_PAD_INDEX 46 // AONIO 6 = GPIO26
|
||||
#define AONIO_6_GPIO_INSTANCE 1
|
||||
#define AONIO_6_GPIO_PIN 10
|
||||
|
||||
#define RTE_CSPI0 0
|
||||
|
||||
#define RTE_CSPI0_MCLK_PAD_ADDR 39
|
||||
#define RTE_CSPI0_MCLK_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI0_PCLK_PAD_ADDR 35
|
||||
#define RTE_CSPI0_PCLK_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI0_CS_PAD_ADDR 36
|
||||
#define RTE_CSPI0_CS_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI0_SDO0_PAD_ADDR 37
|
||||
#define RTE_CSPI0_SDO0_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI0_SDO1_PAD_ADDR 38
|
||||
#define RTE_CSPI0_SDO1_FUNC PAD_MUX_ALT1
|
||||
|
||||
// DMA CSPI0 Request ID
|
||||
#define RTE_CSPI0_DMA_RX_REQID DMA_REQUEST_I2S0_RX
|
||||
|
||||
// CSPI1 Configuration
|
||||
#define RTE_CSPI1 1
|
||||
|
||||
#define RTE_CSPI1_MCLK_PAD_ADDR 18
|
||||
#define RTE_CSPI1_MCLK_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI1_PCLK_PAD_ADDR 19
|
||||
#define RTE_CSPI1_PCLK_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI1_CS_PAD_ADDR 20
|
||||
#define RTE_CSPI1_CS_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI1_SDO0_PAD_ADDR 21
|
||||
#define RTE_CSPI1_SDO0_FUNC PAD_MUX_ALT1
|
||||
|
||||
#define RTE_CSPI1_SDO1_PAD_ADDR 22
|
||||
#define RTE_CSPI1_SDO1_FUNC PAD_MUX_ALT1
|
||||
|
||||
// DMA CSPI1 Request ID
|
||||
#define RTE_CSPI1_DMA_RX_REQID DMA_REQUEST_I2S1_RX
|
||||
|
||||
#endif /* __RTE_DEVICE_H */
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef __AUDIO_EXTERN_H__
|
||||
#define __AUDIO_EXTERN_H__
|
||||
extern const unsigned char audio0[];
|
||||
extern const unsigned char audio1[];
|
||||
extern const unsigned char audio10[];
|
||||
extern const unsigned char audio100[];
|
||||
extern const unsigned char audio1000[];
|
||||
extern const unsigned char audio10000[];
|
||||
extern const unsigned char audio2[];
|
||||
extern const unsigned char audio3[];
|
||||
extern const unsigned char audio4[];
|
||||
extern const unsigned char audio5[];
|
||||
extern const unsigned char audio6[];
|
||||
extern const unsigned char audio7[];
|
||||
extern const unsigned char audio8[];
|
||||
extern const unsigned char audio9[];
|
||||
extern const unsigned char audiodot[];
|
||||
extern const unsigned char audioshoukuanchenggong[];
|
||||
extern const unsigned char audioyuan[];
|
||||
extern const unsigned char audiozhifubao[];
|
||||
extern const int audio0Size;
|
||||
extern const int audio1Size;
|
||||
extern const int audio10Size;
|
||||
extern const int audio100Size;
|
||||
extern const int audio1000Size;
|
||||
extern const int audio10000Size;
|
||||
extern const int audio2Size;
|
||||
extern const int audio3Size;
|
||||
extern const int audio4Size;
|
||||
extern const int audio5Size;
|
||||
extern const int audio6Size;
|
||||
extern const int audio7Size;
|
||||
extern const int audio8Size;
|
||||
extern const int audio9Size;
|
||||
extern const int audiodotSize;
|
||||
extern const int audioshoukuanchenggongSize;
|
||||
extern const int audioyuanSize;
|
||||
extern const int audiozhifubaoSize;
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
#ifndef __AUDIO_TASK__
|
||||
#define __AUDIO_TASK__
|
||||
#include "queue.h"
|
||||
// #include "audio_play.h"
|
||||
#include "luat_audio_play_ec618.h"
|
||||
typedef struct
|
||||
{
|
||||
uint32_t priority;
|
||||
uint32_t playType;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
char *data;
|
||||
uint8_t len;
|
||||
} tts;
|
||||
struct
|
||||
{
|
||||
luat_audio_play_info_t *info;
|
||||
uint8_t count;
|
||||
} file;
|
||||
} message;
|
||||
void * userParam;
|
||||
} audioQueueData;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MONEY_PLAY = 0,
|
||||
PAD_PLAY,
|
||||
SYS_PLAY
|
||||
} AUDIO_PLAY_PRIORITY;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TTS_PLAY = 0,
|
||||
FILE_PLAY,
|
||||
} AUDIO_PLAY_TYPE;
|
||||
|
||||
|
||||
void audio_task_init(void);
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef __MQTT_PUBLISH_H__
|
||||
#define __MQTT_PUBLISH_H__
|
||||
#include "MQTTClient.h"
|
||||
typedef struct mqtt_publish_para
|
||||
{
|
||||
mqttSendMsg* publish;
|
||||
void (*callback)(int result);
|
||||
}mqtt_publish_para_t;
|
||||
|
||||
|
||||
typedef enum MQTT_PUBLISH_RESULT
|
||||
{
|
||||
MQTT_PUBLISH_SUCCESS,
|
||||
MQTT_PUBLISH_FAIL,
|
||||
MQTT_NOT_READY,
|
||||
NETWORK_NOT_READY
|
||||
}MQTT_PUBLISH_RESULT_E;
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef __MQTT_STATUS_H_
|
||||
#define __MQTT_STATUS_H_
|
||||
bool getNetStatus();
|
||||
bool getServerStatus();
|
||||
#endif
|
||||
@@ -0,0 +1,165 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "common_api.h"
|
||||
#include "audio_task.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "audio_extern.h"
|
||||
#include "luat_rtos.h"
|
||||
#include "luat_audio_play_ec618.h"
|
||||
#include "luat_i2s_ec618.h"
|
||||
#include "ivTTSSDKID_all.h"
|
||||
#include "ivTTS.h"
|
||||
#include "luat_gpio.h"
|
||||
#include "luat_debug.h"
|
||||
|
||||
//AIR780E+TM8211开发板配置
|
||||
#define CODEC_PWR_PIN HAL_GPIO_12
|
||||
#define CODEC_PWR_PIN_ALT_FUN 4
|
||||
#define PA_PWR_PIN HAL_GPIO_25
|
||||
#define PA_PWR_PIN_ALT_FUN 0
|
||||
#define CHARGE_EN_PIN HAL_GPIO_2
|
||||
#define CHARGE_EN_PIN_ALT_FUN 0
|
||||
|
||||
#define AUDIO_QUEUE_SIZE 100
|
||||
|
||||
|
||||
extern const unsigned char audiopoweron[];
|
||||
static luat_rtos_semaphore_t audio_semaphore_handle;
|
||||
static luat_rtos_task_handle audio_task_handle;
|
||||
|
||||
|
||||
luat_rtos_queue_t audio_queue_handle;
|
||||
static uint8_t audio_sleep_handler = 0xff;
|
||||
static HANDLE g_s_delay_timer;
|
||||
|
||||
void audio_data_cb(uint8_t *data, uint32_t len, uint8_t bits, uint8_t channels)
|
||||
{
|
||||
int value = 15;
|
||||
int ret = luat_kv_get("volume", &value, sizeof(int));
|
||||
if(ret > 0)
|
||||
{
|
||||
// LUAT_DEBUG_PRINT("cloud_speaker_audio_task get volume success %d", value); //这里的打印打开会出来很多,影响日志查看,有需要可自行打开
|
||||
HAL_I2sSrcAdjustVolumn(data, len, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// LUAT_DEBUG_PRINT("cloud_speaker_audio_task get volume fail %d", value); //这里的打印打开会出来很多,影响日志查看,有需要可自行打开
|
||||
HAL_I2sSrcAdjustVolumn(data, len, 15);
|
||||
}
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task %x,%d,%d,%d,%d", data, len, bits, channels);
|
||||
}
|
||||
void app_pa_on(uint32_t arg)
|
||||
{
|
||||
luat_gpio_set(PA_PWR_PIN, 1); //如果是780E+音频扩展小板,可以注释掉此行代码,因为PA长开
|
||||
}
|
||||
void audio_event_cb(uint32_t event, void *param)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task event_cb %d", event);
|
||||
switch (event)
|
||||
{
|
||||
case MULTIMEDIA_CB_AUDIO_DECODE_START:
|
||||
luat_gpio_set(CODEC_PWR_PIN, 1);
|
||||
luat_audio_play_write_blank_raw(0, 6, 1);
|
||||
break;
|
||||
case MULTIMEDIA_CB_AUDIO_OUTPUT_START:
|
||||
luat_rtos_timer_start(g_s_delay_timer, 200, 0, app_pa_on, NULL); //如果是780E+音频扩展小板,可以注释掉此行代码,因为PA长开
|
||||
break;
|
||||
case MULTIMEDIA_CB_TTS_INIT:
|
||||
break;
|
||||
case LUAT_MULTIMEDIA_CB_TTS_DONE:
|
||||
if (!luat_audio_play_get_last_error(0))
|
||||
{
|
||||
luat_audio_play_write_blank_raw(0, 1, 0);
|
||||
}
|
||||
break;
|
||||
case MULTIMEDIA_CB_AUDIO_DONE:
|
||||
luat_rtos_timer_stop(g_s_delay_timer);
|
||||
LUAT_DEBUG_PRINT("audio play done, result=%d!", luat_audio_play_get_last_error(0));
|
||||
luat_gpio_set(PA_PWR_PIN, 0); //如果是780E+音频扩展小板,可以注释掉此行代码,因为PA长开
|
||||
luat_gpio_set(CODEC_PWR_PIN, 0);
|
||||
luat_rtos_semaphore_release(audio_semaphore_handle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void audio_task(void *param)
|
||||
{
|
||||
audioQueueData audioQueueRecv = {0};
|
||||
uint32_t result = 0;
|
||||
while (1)
|
||||
{
|
||||
if (luat_rtos_queue_recv(audio_queue_handle, &audioQueueRecv, NULL, portMAX_DELAY) == 0)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task this is play priority %d", audioQueueRecv.priority);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task this is play playType %d", audioQueueRecv.playType);
|
||||
if (audioQueueRecv.priority == MONEY_PLAY)
|
||||
{
|
||||
|
||||
if (audioQueueRecv.playType == TTS_PLAY)
|
||||
{
|
||||
luat_audio_play_tts_text(0, audioQueueRecv.message.tts.data, audioQueueRecv.message.tts.len);
|
||||
}
|
||||
else if (audioQueueRecv.playType == FILE_PLAY)
|
||||
{
|
||||
luat_audio_play_multi_files(0, audioQueueRecv.message.file.info, audioQueueRecv.message.file.count);
|
||||
}
|
||||
}
|
||||
else if (audioQueueRecv.priority == PAD_PLAY)
|
||||
{
|
||||
}
|
||||
luat_rtos_semaphore_take(audio_semaphore_handle, LUAT_WAIT_FOREVER);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task this is play wait result %d", result);
|
||||
if (audioQueueRecv.playType == TTS_PLAY) {
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task free tts data");
|
||||
free(audioQueueRecv.message.tts.data);
|
||||
}
|
||||
else if(audioQueueRecv.playType == FILE_PLAY)
|
||||
{
|
||||
free(audioQueueRecv.message.file.info);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task free file data");
|
||||
}
|
||||
}
|
||||
}
|
||||
luat_rtos_task_delete(audio_task_handle);
|
||||
}
|
||||
|
||||
void audio_task_init(void)
|
||||
{
|
||||
luat_rtos_timer_create(&g_s_delay_timer);
|
||||
|
||||
luat_gpio_cfg_t gpio_cfg;
|
||||
luat_gpio_set_default_cfg(&gpio_cfg);
|
||||
|
||||
gpio_cfg.pull = LUAT_GPIO_DEFAULT;
|
||||
|
||||
//如果是780E+音频扩展小板,可以注释掉下面两行代码,因为PA长开
|
||||
gpio_cfg.pin = PA_PWR_PIN;
|
||||
luat_gpio_open(&gpio_cfg);
|
||||
|
||||
gpio_cfg.pin = CODEC_PWR_PIN;
|
||||
luat_gpio_open(&gpio_cfg);
|
||||
gpio_cfg.alt_fun = CODEC_PWR_PIN_ALT_FUN;
|
||||
luat_gpio_open(&gpio_cfg);
|
||||
|
||||
luat_audio_play_global_init(audio_event_cb, audio_data_cb, luat_audio_play_file_default_fun, luat_audio_play_tts_default_fun, NULL);
|
||||
ivCStrA sdk_id = AISOUND_SDK_USERID_16K;
|
||||
luat_audio_play_tts_set_resource(ivtts_16k, sdk_id, NULL);
|
||||
// luat_i2s_base_setup(0, I2S_MODE_I2S, I2S_FRAME_SIZE_16_16); //如果是780E+音频扩展小板,打开这行注释代码,这个配置对应ES7148/ES7149
|
||||
luat_i2s_base_setup(0, I2S_MODE_MSB, I2S_FRAME_SIZE_16_16); //此处配置对应TM8211
|
||||
luat_rtos_semaphore_create(&audio_semaphore_handle, 1);
|
||||
|
||||
luat_rtos_queue_create(&audio_queue_handle, AUDIO_QUEUE_SIZE, sizeof(audioQueueData));
|
||||
audioQueueData powerOn = {0};
|
||||
powerOn.playType = TTS_PLAY;
|
||||
powerOn.priority = MONEY_PLAY;
|
||||
char str[] = "正在开机";
|
||||
powerOn.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(powerOn.message.tts.data, str, sizeof(str));
|
||||
powerOn.message.tts.len = sizeof(str);
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &powerOn, NULL, 0))
|
||||
{
|
||||
free(powerOn.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task start send audio fail");
|
||||
}
|
||||
int result = luat_rtos_task_create(&audio_task_handle, 2048, 20, "mqtt", audio_task, NULL, NULL);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_audio_task create task result %d", result);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "luat_rtos.h"
|
||||
#include "common_api.h"
|
||||
#include "luat_debug.h"
|
||||
#include "luat_adc.h"
|
||||
static luat_rtos_task_handle charge_task_handle;
|
||||
|
||||
#define ADC_ID_VBAT 11
|
||||
static volatile uint16_t vbat = 0;
|
||||
|
||||
uint16_t get_vbat()
|
||||
{
|
||||
return vbat;
|
||||
}
|
||||
|
||||
static void charge_task(void *param)
|
||||
{
|
||||
int origin, revert;
|
||||
luat_adc_open(ADC_ID_VBAT, NULL);
|
||||
luat_adc_read(ADC_ID_VBAT, &origin, &revert);
|
||||
luat_rtos_task_sleep(1000);
|
||||
while (1)
|
||||
{
|
||||
luat_adc_read(ADC_ID_VBAT, &origin, &revert);
|
||||
vbat = revert;
|
||||
luat_rtos_task_sleep(60000);
|
||||
}
|
||||
luat_rtos_task_delete(charge_task_handle);
|
||||
}
|
||||
|
||||
|
||||
void charge_task_init(void)
|
||||
{
|
||||
int result = luat_rtos_task_create(&charge_task_handle, 256, 20, "charge task", charge_task, NULL, NULL);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_charge_task create task result %d", result);
|
||||
}
|
||||
@@ -0,0 +1,696 @@
|
||||
/*
|
||||
* Copyright (c) 2022 OpenLuat & AirM2M
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "bsp.h"
|
||||
#include "bsp_custom.h"
|
||||
#include "common_api.h"
|
||||
#include "cJSON.h"
|
||||
#include "MQTTClient.h"
|
||||
#include "audio_task.h"
|
||||
#include "audio_file.h"
|
||||
#include "math.h"
|
||||
#include "luat_rtos.h"
|
||||
#include "luat_mobile.h"
|
||||
#include "luat_debug.h"
|
||||
#include "luat_pm.h"
|
||||
#include "mqtt_publish.h"
|
||||
uint8_t g_s_is_link_up = 0;
|
||||
static luat_rtos_semaphore_t net_semaphore_handle;
|
||||
static luat_rtos_task_handle mqtt_task_handle;
|
||||
extern luat_rtos_queue_t audio_queue_handle;
|
||||
|
||||
#define MQTT_HOST "lbsmqtt.airm2m.com" // MQTT服务器的地址和端口号
|
||||
#define MQTT_PORT 1884
|
||||
|
||||
#define MQTT_SEND_BUFF_LEN (1024)
|
||||
#define MQTT_RECV_BUFF_LEN (1024)
|
||||
|
||||
#define CLIENTID "12345678"
|
||||
const static char mqtt_sub_topic_head[] = "/sub/topic/money/"; //订阅的主题头,待与设备imei进行拼接
|
||||
const static char mqtt_pub_topic[] = "/pub/topic/message"; //发布的主题
|
||||
static char mqtt_send_payload[] = "hello mqtt_test!!!";
|
||||
static char mqtt_sub_topic[40]; //订阅的主题,待存放订阅的主题头和设备imei,共计17+15,32个字符
|
||||
static bool netStatus = false;
|
||||
static bool serverStatus = false;
|
||||
|
||||
bool getNetStatus()
|
||||
{
|
||||
return netStatus;
|
||||
}
|
||||
bool getServerStatus()
|
||||
{
|
||||
return serverStatus;
|
||||
}
|
||||
|
||||
int fomatMoney(int num, audioQueueData *data, int *index, BOOL flag)
|
||||
{
|
||||
uint32_t audioArray[10][2] =
|
||||
{
|
||||
{audio0, sizeof(audio0)},
|
||||
{audio1, sizeof(audio1)},
|
||||
{audio2, sizeof(audio2)},
|
||||
{audio3, sizeof(audio3)},
|
||||
{audio4, sizeof(audio4)},
|
||||
{audio5, sizeof(audio5)},
|
||||
{audio6, sizeof(audio6)},
|
||||
{audio7, sizeof(audio7)},
|
||||
{audio8, sizeof(audio8)},
|
||||
{audio9, sizeof(audio9)}
|
||||
};
|
||||
int thousand = (num - num % 1000) / 1000;
|
||||
int hundred = ((num % 1000) - ((num % 1000) % 100)) / 100;
|
||||
int ten = ((num % 100) - ((num % 100) % 10)) / 10;
|
||||
int unit = num % 10;
|
||||
if (thousand == 0)
|
||||
{
|
||||
thousand = -1;
|
||||
if (hundred == 0)
|
||||
{
|
||||
hundred = -1;
|
||||
if (ten == 0)
|
||||
{
|
||||
ten = -1;
|
||||
if (unit == 0)
|
||||
{
|
||||
unit = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unit == 0)
|
||||
{
|
||||
unit = -1;
|
||||
if (ten == 0)
|
||||
{
|
||||
ten = -1;
|
||||
if (hundred == 0)
|
||||
{
|
||||
hundred = -1;
|
||||
if (thousand == 0)
|
||||
{
|
||||
thousand = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ten == 0 && hundred == 0)
|
||||
{
|
||||
ten = -1;
|
||||
}
|
||||
if (thousand != -1)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
if(2 == thousand)
|
||||
{
|
||||
data->message.file.info[*index].address = audioliang;
|
||||
data->message.file.info[*index].rom_data_len = audioliangSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->message.file.info[*index].address = audioArray[thousand][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[thousand][1];
|
||||
}
|
||||
}
|
||||
*index += 1;
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audio1000;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audio1000);
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
if (hundred != -1)
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
if(2 == hundred)
|
||||
{
|
||||
data->message.file.info[*index].address = audioliang;
|
||||
data->message.file.info[*index].rom_data_len = audioliangSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->message.file.info[*index].address = audioArray[hundred][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[hundred][1];
|
||||
}
|
||||
}
|
||||
*index += 1;
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audio100;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audio100);
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
if (ten != -1)
|
||||
{
|
||||
if (!(ten == 1 && hundred == -1 && thousand == -1))
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[ten][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[ten][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
if (ten != 0)
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audio10;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audio10);
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
}
|
||||
if (unit != -1)
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[unit][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[unit][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int strToFile(char *money, audioQueueData *data, int *index, bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].address = audiozhifubao;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audiozhifubao);
|
||||
}
|
||||
*index += 1;
|
||||
uint32_t audioArray[10][2] =
|
||||
{
|
||||
{audio0, sizeof(audio0)},
|
||||
{audio1, sizeof(audio1)},
|
||||
{audio2, sizeof(audio2)},
|
||||
{audio3, sizeof(audio3)},
|
||||
{audio4, sizeof(audio4)},
|
||||
{audio5, sizeof(audio5)},
|
||||
{audio6, sizeof(audio6)},
|
||||
{audio7, sizeof(audio7)},
|
||||
{audio8, sizeof(audio8)},
|
||||
{audio9, sizeof(audio9)}
|
||||
};
|
||||
int count = 0;
|
||||
int integer = 0;
|
||||
char *str = NULL;
|
||||
char intStr[8] = {0};
|
||||
char decStr[3] = {0};
|
||||
str = strstr(money, ".");
|
||||
if (str != NULL)
|
||||
{
|
||||
memcpy(intStr, money, str - money);
|
||||
str = str + 1;
|
||||
memcpy(decStr, str, 2);
|
||||
integer = atoi(intStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
integer = atoi(money);
|
||||
}
|
||||
if (integer >= 10000)
|
||||
{
|
||||
int filecount = fomatMoney(integer / 10000, data, index, flag);
|
||||
if (flag)
|
||||
{
|
||||
if((2 == *index) && (data->message.file.info[1].address == audio2))
|
||||
{
|
||||
data->message.file.info[1].address = audioliang;
|
||||
data->message.file.info[1].rom_data_len = sizeof(audioliang);
|
||||
}
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audio10000;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audio10000);
|
||||
}
|
||||
*index += 1;
|
||||
if (((integer % 10000) < 1000) && ((integer % 10000) != 0))
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[0][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[0][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
}
|
||||
if ((integer % 10000) > 0)
|
||||
{
|
||||
int filecount = fomatMoney(integer % 10000, data, index, flag);
|
||||
}
|
||||
if (*index == 1)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[0][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[0][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
int fraction = atoi(decStr);
|
||||
if (fraction > 0)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audiodot;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audiodot);
|
||||
}
|
||||
*index += 1;
|
||||
if (fraction >= 10)
|
||||
{
|
||||
int ten = fraction / 10;
|
||||
int unit = fraction % 10;
|
||||
if (ten != 0 && unit != 0)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[ten][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[ten][1];
|
||||
}
|
||||
*index += 1;
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[unit][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[unit][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
else if(ten == 0 && unit!=0)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[0][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[0][1];
|
||||
}
|
||||
*index += 1;
|
||||
if(flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[unit][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[0][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
else if(ten !=0 && unit == 0)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[ten][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[ten][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(decStr[0] == 0x30)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[0][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[0][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioArray[fraction][0];
|
||||
data->message.file.info[*index].rom_data_len = audioArray[fraction][1];
|
||||
}
|
||||
*index += 1;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
data->message.file.info[*index].path = NULL;
|
||||
data->message.file.info[*index].address = audioyuan;
|
||||
data->message.file.info[*index].rom_data_len = sizeof(audioyuan);
|
||||
}
|
||||
*index += 1;
|
||||
return count;
|
||||
}
|
||||
|
||||
void messageArrived(MessageData* data)
|
||||
{
|
||||
if (strcmp(mqtt_sub_topic, data->topicName->lenstring.data) == 0)
|
||||
{
|
||||
cJSON *boss = NULL;
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt mqtt Message arrived on topic %.*s: %.*s\n", data->topicName->lenstring.len, data->topicName->lenstring.data, data->message->payloadlen, data->message->payload);
|
||||
boss = cJSON_Parse((const char *)data->message->payload);
|
||||
if (boss == NULL){
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt cjson parse fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt cjson parse success");
|
||||
cJSON *money = cJSON_GetObjectItem(boss, "money");
|
||||
if(money == NULL)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt Missing amount field %d", money);
|
||||
return 0;
|
||||
}
|
||||
if (cJSON_IsString(money))
|
||||
{
|
||||
audioQueueData moneyPlay = {0};
|
||||
moneyPlay.priority = MONEY_PLAY;
|
||||
moneyPlay.playType = FILE_PLAY;
|
||||
char* str = NULL;
|
||||
str = strstr(money->valuestring, ".");
|
||||
//判断金额长度是否大于8个,也就是千万级别的金额,如果是,则播报收款成功,如果不是,则播报对应金额,这里并未对金额字段做合法性判断
|
||||
if (str != NULL)
|
||||
{
|
||||
if((str - money->valuestring) > 8)
|
||||
{
|
||||
moneyPlay.message.file.info = (audio_play_info_t *)calloc(1, sizeof(audio_play_info_t));
|
||||
moneyPlay.message.file.info->address = audioshoukuanchenggong;
|
||||
moneyPlay.message.file.info->rom_data_len = audioshoukuanchenggongSize;
|
||||
moneyPlay.message.file.count = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
str++;
|
||||
//如果小数点位数大于两位,则说明数字金额不合法,播报收款成功
|
||||
if(strlen(str) > 2)
|
||||
{
|
||||
moneyPlay.message.file.info = (audio_play_info_t *)calloc(1, sizeof(audio_play_info_t));
|
||||
moneyPlay.message.file.info->address = audioshoukuanchenggong;
|
||||
moneyPlay.message.file.info->rom_data_len = audioshoukuanchenggongSize;
|
||||
moneyPlay.message.file.count = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//调用strToFile来将金额格式化为对应的文件播报数据,需要调用两次,第一次获取需要malloc的空间,第二次将文件数据放进空间里
|
||||
int index = 0;
|
||||
strToFile(money->valuestring, &moneyPlay, &index, false);
|
||||
moneyPlay.message.file.info = (audio_play_info_t *)calloc(index, sizeof(audio_play_info_t));
|
||||
index = 0;
|
||||
strToFile(money->valuestring, &moneyPlay, &index, true);
|
||||
moneyPlay.message.file.count = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strlen(money->valuestring) > 8)
|
||||
{
|
||||
moneyPlay.message.file.info = (audio_play_info_t *)calloc(1, sizeof(audio_play_info_t));
|
||||
moneyPlay.message.file.info->address = audioshoukuanchenggong;
|
||||
moneyPlay.message.file.info->rom_data_len = audioshoukuanchenggongSize;
|
||||
moneyPlay.message.file.count = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//调用strToFile来将金额格式化为对应的文件播报数据,需要调用两次,第一次获取需要malloc的空间,第二次将文件数据放进空间里
|
||||
int index = 0;
|
||||
strToFile(money->valuestring, &moneyPlay, &index, false);
|
||||
moneyPlay.message.file.info = (audio_play_info_t *)calloc(index, sizeof(audio_play_info_t));
|
||||
index = 0;
|
||||
strToFile(money->valuestring, &moneyPlay, &index, true);
|
||||
moneyPlay.message.file.count = index;
|
||||
}
|
||||
}
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &moneyPlay, NULL, 0)){
|
||||
free(moneyPlay.message.file.info);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt sub queue send error");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt money data is invalid %d", cJSON_IsString(money));
|
||||
}
|
||||
}
|
||||
cJSON_Delete(boss);
|
||||
}
|
||||
}
|
||||
|
||||
static void mobile_event_cb(LUAT_MOBILE_EVENT_E event, uint8_t index, uint8_t status)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
case LUAT_MOBILE_EVENT_CFUN:
|
||||
LUAT_DEBUG_PRINT("CFUN消息,status %d", status);
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_SIM:
|
||||
LUAT_DEBUG_PRINT("SIM卡消息");
|
||||
switch(status)
|
||||
{
|
||||
case LUAT_MOBILE_SIM_READY:
|
||||
LUAT_DEBUG_PRINT("SIM卡正常工作");
|
||||
break;
|
||||
case LUAT_MOBILE_NO_SIM:
|
||||
LUAT_DEBUG_PRINT("SIM卡不存在");
|
||||
break;
|
||||
case LUAT_MOBILE_SIM_NEED_PIN:
|
||||
LUAT_DEBUG_PRINT("SIM卡需要输入PIN码");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_REGISTER_STATUS:
|
||||
LUAT_DEBUG_PRINT("移动网络服务状态变更,当前为%d", status);
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_CELL_INFO:
|
||||
switch(status)
|
||||
{
|
||||
case LUAT_MOBILE_CELL_INFO_UPDATE:
|
||||
break;
|
||||
case LUAT_MOBILE_SIGNAL_UPDATE:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_PDP:
|
||||
LUAT_DEBUG_PRINT("CID %d PDP激活状态变更为 %d", index, status);
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_NETIF:
|
||||
LUAT_DEBUG_PRINT("internet工作状态变更为 %d", status);
|
||||
switch (status)
|
||||
{
|
||||
case LUAT_MOBILE_NETIF_LINK_ON:
|
||||
LUAT_DEBUG_PRINT("可以上网");
|
||||
g_s_is_link_up = 1;
|
||||
break;
|
||||
default:
|
||||
g_s_is_link_up = 0;
|
||||
LUAT_DEBUG_PRINT("不能上网");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_TIME_SYNC:
|
||||
LUAT_DEBUG_PRINT("通过移动网络同步了UTC时间");
|
||||
break;
|
||||
case LUAT_MOBILE_EVENT_CSCON:
|
||||
LUAT_DEBUG_PRINT("RRC状态 %d", status);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
extern luat_rtos_task_handle mqtt_publish_task_handle;
|
||||
extern void mqtt_publish_task(void *args);
|
||||
static void mqtt_demo(void){
|
||||
int rc = 0;
|
||||
unsigned char mqttSendbuf[MQTT_SEND_BUFF_LEN] = {0}, mqttReadbuf[MQTT_RECV_BUFF_LEN] = {0};
|
||||
static MQTTClient mqttClient;
|
||||
static Network n = {0};
|
||||
|
||||
MQTTMessage message = {0};
|
||||
MQTTPacket_connectData connectData = MQTTPacket_connectData_initializer;
|
||||
connectData.MQTTVersion = 4;
|
||||
int ret = 0;
|
||||
char str[32] = {0};
|
||||
char clientId[17] = {0};
|
||||
char username[17] = {0};
|
||||
char password[17] = {0};
|
||||
ret = luat_kv_get("clientId", str, 17); //从数据库中读取clientId
|
||||
if(ret > 0 )
|
||||
{
|
||||
memcpy(clientId, str, 16); //留一位确保字符串结尾能有0x00
|
||||
connectData.clientID.cstring = clientId;
|
||||
}
|
||||
else //数据库中没有写入过clientId,获取设备imei作为clientId
|
||||
{
|
||||
int result = 0;
|
||||
result = luat_mobile_get_imei(0, clientId, 15); //imei是15位,留一个位置放0x00
|
||||
if(result <= 0)
|
||||
{
|
||||
connectData.clientID.cstring = CLIENTID;
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt clientid get fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
connectData.clientID.cstring = clientId;
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt clientid get success %s", clientId);
|
||||
}
|
||||
}
|
||||
memset(str, 0, 32);
|
||||
ret = luat_kv_get("username", str, 17); //从数据库中读取username,如果没读到,则用默认的
|
||||
if(ret > 0 )
|
||||
{
|
||||
memcpy(username, str, 16); //留一位确保字符串结尾能有0x00
|
||||
connectData.username.cstring = username;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectData.username.cstring = NULL;
|
||||
}
|
||||
memset(str, 0, 32);
|
||||
ret = luat_kv_get("password", str, 17); //从数据库中读取password,如果没读到,则用默认的
|
||||
if(ret > 0 )
|
||||
{
|
||||
memcpy(password, str, 16); //留一位确保字符串结尾能有0x00
|
||||
connectData.password.cstring = password;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectData.password.cstring = NULL;
|
||||
}
|
||||
memset(str, 0, 32);
|
||||
memset(mqtt_sub_topic, 0x00, sizeof(mqtt_sub_topic));
|
||||
snprintf(mqtt_sub_topic, 40, "%s%s", mqtt_sub_topic_head, clientId);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt subscribe_topic %s %s %s %s", mqtt_sub_topic, clientId, username, password);
|
||||
connectData.keepAliveInterval = 120;
|
||||
|
||||
while(!g_s_is_link_up)
|
||||
{
|
||||
luat_rtos_task_sleep(1000);
|
||||
}
|
||||
// 设置my_app标记可以休眠到LIGHT等级
|
||||
luat_pm_set_sleep_mode(LUAT_PM_SLEEP_MODE_LIGHT, "my_app");
|
||||
|
||||
NetworkInit(&n);
|
||||
MQTTClientInit(&mqttClient, &n, 40000, mqttSendbuf, MQTT_SEND_BUFF_LEN, mqttReadbuf, MQTT_RECV_BUFF_LEN);
|
||||
|
||||
if ((NetworkConnect(&n, MQTT_HOST, MQTT_PORT)) != 0){
|
||||
mqttClient.keepAliveInterval = connectData.keepAliveInterval;
|
||||
mqttClient.ping_outstanding = 1;
|
||||
goto error;
|
||||
}else{
|
||||
if ((MQTTConnect(&mqttClient, &connectData)) != 0){
|
||||
mqttClient.ping_outstanding = 1;
|
||||
goto error;
|
||||
}else{
|
||||
LUAT_DEBUG_PRINT("MQTTStartTask \n");
|
||||
#if defined(MQTT_TASK)
|
||||
if ((MQTTStartTask(&mqttClient)) != pdPASS){
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
while (1){
|
||||
// 支付报文一般来说不能丢失,也最好不要重复发送,这里设置qos为1即可,保证只收到一次
|
||||
if ((rc = MQTTSubscribe(&mqttClient, mqtt_sub_topic, 1, messageArrived)) != 0)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("mqtt Return code from MQTT subscribe error is %d\n", rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
serverStatus = true;
|
||||
audioQueueData welcome = {0};
|
||||
welcome.playType = TTS_PLAY;
|
||||
welcome.priority = MONEY_PLAY;
|
||||
char str[] = "服务器连接成功";
|
||||
welcome.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(welcome.message.tts.data, str, sizeof(str));
|
||||
welcome.message.tts.len = sizeof(str);
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &welcome, NULL, 0)){
|
||||
free(welcome.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt sub audio queue send error");
|
||||
}
|
||||
if (mqtt_publish_task_handle == NULL)
|
||||
{
|
||||
luat_rtos_task_create(&mqtt_publish_task_handle, 2048, 20, "mqtt_publish_task", mqtt_publish_task, (void *)&mqttClient, 10);
|
||||
}
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
if(MQTTIsConnected(&mqttClient) == 0){
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
luat_rtos_task_sleep(5000);
|
||||
}
|
||||
error:
|
||||
while(!g_s_is_link_up){
|
||||
luat_rtos_task_sleep(1000);
|
||||
}
|
||||
|
||||
if (rc = MQTTReConnect(&mqttClient, &connectData) != 0){
|
||||
luat_rtos_task_sleep(5000);
|
||||
LUAT_DEBUG_PRINT("MQTTReConnect %d\n", rc);
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
LUAT_DEBUG_PRINT("MQTTReConnect OK");
|
||||
}
|
||||
}
|
||||
luat_rtos_task_delete(mqtt_task_handle);
|
||||
}
|
||||
|
||||
static void task_init(void){
|
||||
luat_mobile_event_register_handler(mobile_event_cb);
|
||||
}
|
||||
|
||||
static void mqttclient_task_init(void){
|
||||
int result = luat_rtos_task_create(&mqtt_task_handle, 4096, 20, "mqtt", mqtt_demo, NULL, NULL);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_mqtt create task result %d", result);
|
||||
}
|
||||
|
||||
extern void led_task_init(void);
|
||||
extern void key_task_init(void);
|
||||
extern void charge_task_init(void);
|
||||
extern void usb_uart_init(void);
|
||||
extern void fdb_init(void);
|
||||
extern void mqtt_send_task_init(void);
|
||||
|
||||
|
||||
INIT_HW_EXPORT(task_init, "1");
|
||||
INIT_HW_EXPORT(fdb_init, "1");
|
||||
INIT_TASK_EXPORT(mqttclient_task_init, "2");
|
||||
INIT_TASK_EXPORT(audio_task_init, "2");
|
||||
INIT_TASK_EXPORT(led_task_init, "2");
|
||||
INIT_TASK_EXPORT(key_task_init, "3");
|
||||
INIT_TASK_EXPORT(charge_task_init, "2");
|
||||
INIT_TASK_EXPORT(usb_uart_init, "2");
|
||||
INIT_TASK_EXPORT(mqtt_send_task_init, "3");
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "luat_rtos.h"
|
||||
#include "luat_gpio.h"
|
||||
#include "common_api.h"
|
||||
#include "luat_debug.h"
|
||||
#include "luat_pm.h"
|
||||
#include "audio_task.h"
|
||||
#define KEY1_MESSAGE (0x1)
|
||||
#define KEY2_MESSAGE (0x2)
|
||||
#define KEY3_MESSAGE (0x3)
|
||||
#define PWR_MESSAGE (0x4)
|
||||
#define CHARGE_START_MESSAGE (0x5)
|
||||
#define CHARGE_END_MESSAGE (0x6)
|
||||
|
||||
#define PAD_PIN_ALT_FUN 0
|
||||
#define KEY_QUEUE_SIZE 2
|
||||
extern uint16_t get_vbat();
|
||||
typedef struct
|
||||
{
|
||||
uint8_t messageId;
|
||||
} key_message_t;
|
||||
|
||||
static luat_rtos_task_handle key_task_handle;
|
||||
static luat_rtos_queue_t key_queue_handle;
|
||||
static luat_rtos_timer_t pwrkey_timer_handle;
|
||||
static luat_rtos_timer_t powoff_timer_handle;
|
||||
extern luat_rtos_queue_t audio_queue_handle;
|
||||
|
||||
static luat_rtos_timer_callback_t pwrkey_long_press_callback(void *param)
|
||||
{
|
||||
if (param == &pwrkey_timer_handle)
|
||||
{
|
||||
luat_stop_rtos_timer(pwrkey_timer_handle);
|
||||
luat_rtos_timer_start(powoff_timer_handle, 3000, 0, pwrkey_long_press_callback, &powoff_timer_handle);
|
||||
audioQueueData powerOff = {0};
|
||||
powerOff.playType = TTS_PLAY;
|
||||
powerOff.priority = MONEY_PLAY;
|
||||
char str[] = "正在关机";
|
||||
powerOff.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(powerOff.message.tts.data, str, sizeof(str));
|
||||
powerOff.message.tts.len = sizeof(str);
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &powerOff, NULL, 0))
|
||||
{
|
||||
free(powerOff.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
}
|
||||
else if (param == &powoff_timer_handle)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("poweroff");
|
||||
luat_pm_poweroff();
|
||||
}
|
||||
}
|
||||
|
||||
luat_pm_pwrkey_callback_t pwrkey_callback(LUAT_PM_POWERKEY_STATE_E status)
|
||||
{
|
||||
if (LUAT_PM_PWRKEY_PRESS == status)
|
||||
{
|
||||
luat_rtos_timer_start(pwrkey_timer_handle, 3000, 0, pwrkey_long_press_callback, &pwrkey_timer_handle);
|
||||
}
|
||||
else if (LUAT_PM_PWRKEY_RELEASE == status)
|
||||
{
|
||||
uint8_t id = PWR_MESSAGE;
|
||||
luat_rtos_queue_send(key_queue_handle, &id, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void key_task(void *param)
|
||||
{
|
||||
uint8_t msgId = 0;
|
||||
int volume = 15;
|
||||
int ret = 0;
|
||||
while (1)
|
||||
{
|
||||
if (luat_rtos_queue_recv(key_queue_handle, &msgId, NULL, LUAT_WAIT_FOREVER) == 0)
|
||||
{
|
||||
switch (msgId)
|
||||
{
|
||||
case KEY1_MESSAGE:
|
||||
{
|
||||
audioQueueData volMinus = {0};
|
||||
volMinus.playType = TTS_PLAY;
|
||||
volMinus.priority = MONEY_PLAY;
|
||||
volume = 15;
|
||||
ret = luat_kv_get("volume", &volume, sizeof(int));
|
||||
if (ret > 0)
|
||||
{
|
||||
if (volume > 3)
|
||||
{
|
||||
volume = volume - 3;
|
||||
if (volume < 3)
|
||||
{
|
||||
volume = 3;
|
||||
}
|
||||
luat_kv_set("volume", &volume, sizeof(int));
|
||||
}
|
||||
if (volume == 3)
|
||||
{
|
||||
char str[] = "音量最小";
|
||||
volMinus.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(volMinus.message.tts.data, str, sizeof(str));
|
||||
volMinus.message.tts.len = sizeof(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
char str[] = "音量减";
|
||||
volMinus.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(volMinus.message.tts.data, str, sizeof(str));
|
||||
volMinus.message.tts.len = sizeof(str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char str[] = "音量减";
|
||||
volMinus.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(volMinus.message.tts.data, str, sizeof(str));
|
||||
volMinus.message.tts.len = sizeof(str);
|
||||
}
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &volMinus, NULL, 0))
|
||||
{
|
||||
free(volMinus.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY2_MESSAGE:
|
||||
{
|
||||
audioQueueData volPlus = {0};
|
||||
volPlus.playType = TTS_PLAY;
|
||||
volPlus.priority = MONEY_PLAY;
|
||||
volume = 4;
|
||||
ret = luat_kv_get("volume", &volume, sizeof(int));
|
||||
if (ret > 0)
|
||||
{
|
||||
if (volume < 21)
|
||||
{
|
||||
volume = volume + 3;
|
||||
if (volume > 21)
|
||||
{
|
||||
volume = 21;
|
||||
}
|
||||
luat_kv_set("volume", &volume, sizeof(int));
|
||||
}
|
||||
if (volume == 21)
|
||||
{
|
||||
char str[] = "音量最大";
|
||||
volPlus.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(volPlus.message.tts.data, str, sizeof(str));
|
||||
volPlus.message.tts.len = sizeof(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
char str[] = "音量加";
|
||||
volPlus.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(volPlus.message.tts.data, str, sizeof(str));
|
||||
volPlus.message.tts.len = sizeof(str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char str[] = "音量加";
|
||||
volPlus.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(volPlus.message.tts.data, str, sizeof(str));
|
||||
volPlus.message.tts.len = sizeof(str);
|
||||
}
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &volPlus, NULL, 0))
|
||||
{
|
||||
free(volPlus.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY3_MESSAGE:
|
||||
{
|
||||
audioQueueData func = {0};
|
||||
func.playType = TTS_PLAY;
|
||||
func.priority = MONEY_PLAY;
|
||||
char str[] = "功能键";
|
||||
func.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(func.message.tts.data, str, sizeof(str));
|
||||
func.message.tts.len = sizeof(str);
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &func, NULL, 0))
|
||||
{
|
||||
free(func.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PWR_MESSAGE:
|
||||
{
|
||||
if (1 == luat_rtos_timer_is_active(pwrkey_timer_handle))
|
||||
{
|
||||
luat_stop_rtos_timer(pwrkey_timer_handle);
|
||||
uint16_t vbat = get_vbat();
|
||||
audioQueueData currentElec = {0};
|
||||
currentElec.playType = TTS_PLAY;
|
||||
currentElec.priority = MONEY_PLAY;
|
||||
if (vbat > 4000)
|
||||
{
|
||||
char str[] = "当前电量高";
|
||||
currentElec.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(currentElec.message.tts.data, str, sizeof(str));
|
||||
currentElec.message.tts.len = sizeof(str);
|
||||
}
|
||||
else if (vbat > 3700 && vbat < 4000)
|
||||
{
|
||||
char str[] = "当前电量中";
|
||||
currentElec.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(currentElec.message.tts.data, str, sizeof(str));
|
||||
currentElec.message.tts.len = sizeof(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
char str[] = "当前电量低";
|
||||
currentElec.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(currentElec.message.tts.data, str, sizeof(str));
|
||||
currentElec.message.tts.len = sizeof(str);
|
||||
}
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, ¤tElec, NULL, 0))
|
||||
{
|
||||
free(currentElec.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGE_START_MESSAGE:
|
||||
{
|
||||
audioQueueData chargeIn = {0};
|
||||
chargeIn.playType = TTS_PLAY;
|
||||
chargeIn.priority = MONEY_PLAY;
|
||||
char str[] = "正在充电";
|
||||
chargeIn.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(chargeIn.message.tts.data, str, sizeof(str));
|
||||
chargeIn.message.tts.len = sizeof(str);
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &chargeIn, NULL, 0))
|
||||
{
|
||||
free(chargeIn.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGE_END_MESSAGE:
|
||||
{
|
||||
audioQueueData chargeOut = {0};
|
||||
chargeOut.playType = TTS_PLAY;
|
||||
chargeOut.priority = MONEY_PLAY;
|
||||
char str[] = "充电结束";
|
||||
chargeOut.message.tts.data = malloc(sizeof(str));
|
||||
memcpy(chargeOut.message.tts.data, str, sizeof(str));
|
||||
chargeOut.message.tts.len = sizeof(str);
|
||||
if (-1 == luat_rtos_queue_send(audio_queue_handle, &chargeOut, NULL, 0))
|
||||
{
|
||||
free(chargeOut.message.tts.data);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task start send audio fail");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
luat_rtos_task_delete(key_task_handle);
|
||||
}
|
||||
|
||||
luat_pm_wakeup_pad_isr_callback_t down_key_callback(int num)
|
||||
{
|
||||
if (LUAT_PM_WAKEUP_PAD_0 == num)
|
||||
{
|
||||
if (0 == luat_pm_wakeup_pad_get_value(LUAT_PM_WAKEUP_PAD_0))
|
||||
{
|
||||
uint8_t id = KEY1_MESSAGE;
|
||||
luat_rtos_queue_send(key_queue_handle, &id, NULL, 0);
|
||||
}
|
||||
}
|
||||
else if (LUAT_PM_WAKEUP_PAD_3 == num)
|
||||
{
|
||||
if (0 == luat_pm_wakeup_pad_get_value(LUAT_PM_WAKEUP_PAD_3))
|
||||
{
|
||||
uint8_t id = KEY2_MESSAGE;
|
||||
luat_rtos_queue_send(key_queue_handle, &id, NULL, 0);
|
||||
}
|
||||
}
|
||||
else if (LUAT_PM_WAKEUP_PAD_4 == num)
|
||||
{
|
||||
if (0 == luat_pm_wakeup_pad_get_value(LUAT_PM_WAKEUP_PAD_4))
|
||||
{
|
||||
uint8_t id = KEY3_MESSAGE;
|
||||
luat_rtos_queue_send(key_queue_handle, &id, NULL, 0);
|
||||
}
|
||||
}
|
||||
// 新的开发板如果不接电池只插usb,这个中断会一直触发
|
||||
/* else if (LUAT_PM_WAKEUP_PAD_5 == num)
|
||||
{
|
||||
if (0 == luat_pm_wakeup_pad_get_value(LUAT_PM_WAKEUP_PAD_5))
|
||||
{
|
||||
uint8_t id = CHARGE_START_MESSAGE;
|
||||
luat_rtos_queue_send(key_queue_handle, &id, NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t id = CHARGE_END_MESSAGE;
|
||||
luat_rtos_queue_send(key_queue_handle, &id, NULL, 0);
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
void key_task_init(void)
|
||||
{
|
||||
|
||||
luat_rtos_timer_create(&pwrkey_timer_handle);
|
||||
luat_rtos_timer_create(&powoff_timer_handle);
|
||||
|
||||
luat_pm_wakeup_pad_set_callback(down_key_callback);
|
||||
luat_pm_wakeup_pad_cfg_t cfg = {0};
|
||||
cfg.neg_edge_enable = 1;
|
||||
cfg.pos_edge_enable = 0;
|
||||
cfg.pull_up_enable = 1;
|
||||
cfg.pull_down_enable = 0;
|
||||
luat_pm_wakeup_pad_set(true, LUAT_PM_WAKEUP_PAD_0, &cfg);
|
||||
luat_pm_wakeup_pad_set(true, LUAT_PM_WAKEUP_PAD_3, &cfg);
|
||||
luat_pm_wakeup_pad_set(true, LUAT_PM_WAKEUP_PAD_4, &cfg);
|
||||
// 新的开发板如果不接电池只插usb,这个中断会一直触发
|
||||
/* cfg.pos_edge_enable = 1;
|
||||
luat_pm_wakeup_pad_set(true, LUAT_PM_WAKEUP_PAD_5, &cfg); */
|
||||
luat_pm_pwrkey_cfg_t pwrkey_cfg = {0};
|
||||
pwrkey_cfg.long_press_timeout = 3000;
|
||||
pwrkey_cfg.repeat_timeout = 3000;
|
||||
luat_pm_set_pwrkey(LUAT_PM_PWRKEY_WAKEUP_LOWACTIVE_MODE, true, &pwrkey_cfg, pwrkey_callback);
|
||||
|
||||
luat_rtos_queue_create(&key_queue_handle, KEY_QUEUE_SIZE, sizeof(key_message_t));
|
||||
int result = luat_rtos_task_create(&key_task_handle, 1024, 20, "key task", key_task, NULL, NULL);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_key_task create task result %d", result);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "common_api.h"
|
||||
#include "luat_debug.h"
|
||||
void fdb_init(void)
|
||||
{
|
||||
luat_kv_init();
|
||||
char value[2];
|
||||
int ret = luat_kv_get("flag", value, 2);
|
||||
//读取kv数据库用户是否初始化过,如果没有,则写入一个flag和需要初始化的值,表示用户已初始化;如果用户初始化过,则不做任何操作
|
||||
LUAT_DEBUG_PRINT("get value result %d", ret);
|
||||
if (ret > 0)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("get value %s", value);
|
||||
if(memcmp("1", value, strlen("1")))
|
||||
{
|
||||
LUAT_DEBUG_PRINT("need init");
|
||||
ret = luat_kv_set("flag", "1", 2);
|
||||
LUAT_DEBUG_PRINT("init result1 %d", ret);
|
||||
int volume = 15;
|
||||
ret = luat_kv_set("volume", &volume, sizeof(int));
|
||||
}
|
||||
else
|
||||
{
|
||||
LUAT_DEBUG_PRINT("no need init");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = luat_kv_set("flag", "1", 2);
|
||||
int volume = 15;
|
||||
ret = luat_kv_set("volume", &volume, sizeof(int));
|
||||
LUAT_DEBUG_PRINT("init result2 %d", ret);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
#include "luat_rtos.h"
|
||||
#include "luat_gpio.h"
|
||||
#include "common_api.h"
|
||||
#include "luat_debug.h"
|
||||
|
||||
#define LED_PIN_ALT_FUN 0
|
||||
|
||||
#define LED1_PIN HAL_GPIO_24
|
||||
#define LED2_PIN HAL_GPIO_28
|
||||
#define LED3_PIN HAL_GPIO_27
|
||||
|
||||
static luat_rtos_task_handle led_task_handle;
|
||||
|
||||
static void led_task(void *param)
|
||||
{
|
||||
luat_gpio_cfg_t gpio_cfg;
|
||||
luat_gpio_set_default_cfg(&gpio_cfg);
|
||||
luat_rtos_task_handle task_handle;
|
||||
|
||||
gpio_cfg.pull = LUAT_GPIO_DEFAULT;
|
||||
|
||||
//如果是780E+音频扩展小板,需要注释掉下面四行代码,因为这个板子上只有一个可控LED
|
||||
gpio_cfg.pin = LED1_PIN;
|
||||
luat_gpio_open(&gpio_cfg);
|
||||
gpio_cfg.pin = LED2_PIN;
|
||||
luat_gpio_open(&gpio_cfg);
|
||||
|
||||
|
||||
gpio_cfg.pin = LED3_PIN;
|
||||
luat_gpio_open(&gpio_cfg);
|
||||
|
||||
while (1)
|
||||
{
|
||||
luat_rtos_task_sleep(200);
|
||||
luat_gpio_set(LED1_PIN, 1); //如果是780E+音频扩展小板,需要注释掉此行代码
|
||||
luat_gpio_set(LED2_PIN, 1); //如果是780E+音频扩展小板,需要注释掉此行代码
|
||||
luat_gpio_set(LED3_PIN, 1);
|
||||
luat_rtos_task_sleep(200);
|
||||
luat_gpio_set(LED1_PIN, 0); //如果是780E+音频扩展小板,需要注释掉此行代码
|
||||
luat_gpio_set(LED2_PIN, 0); //如果是780E+音频扩展小板,需要注释掉此行代码
|
||||
luat_gpio_set(LED3_PIN, 0);
|
||||
}
|
||||
luat_rtos_task_delete(led_task_handle);
|
||||
}
|
||||
|
||||
void led_task_init(void)
|
||||
{
|
||||
int result = luat_rtos_task_create(&led_task_handle, 256, 20, "led task", led_task, NULL, NULL);
|
||||
LUAT_DEBUG_PRINT("cloud_speaker_led_task create task result %d", result);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "luat_debug.h"
|
||||
#include "luat_rtos.h"
|
||||
#include "mqtt_publish.h"
|
||||
#include "MQTTClient.h"
|
||||
luat_rtos_task_handle mqtt_publish_task_handle = NULL;
|
||||
extern uint8_t g_s_is_link_up;
|
||||
void mqtt_publish_task(void *args)
|
||||
{
|
||||
uint32_t id; // 暂时没什么用,因为只有publish的时候才会触发这条消息
|
||||
int rc;
|
||||
MQTTClient *mqttClient;
|
||||
mqttClient = (MQTTClient *)(args);
|
||||
mqtt_publish_para_t *publish_para = NULL;
|
||||
while (1)
|
||||
{
|
||||
if (luat_rtos_message_recv(mqtt_publish_task_handle, &id, (void **)&publish_para, LUAT_WAIT_FOREVER) == 0)
|
||||
{
|
||||
if (!g_s_is_link_up)
|
||||
{
|
||||
if (publish_para->callback != NULL)
|
||||
publish_para->callback(NETWORK_NOT_READY);
|
||||
}
|
||||
else if (MQTTIsConnected(&mqttClient) == 0)
|
||||
{
|
||||
if (publish_para->callback != NULL)
|
||||
publish_para->callback(MQTT_NOT_READY);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = MQTTPublish(mqttClient, publish_para->publish->topic, &publish_para->publish->message);
|
||||
if (rc != 0)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("MQTTPublish error %d", rc);
|
||||
if (publish_para->callback != NULL)
|
||||
publish_para->callback(MQTT_PUBLISH_FAIL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (publish_para->callback != NULL)
|
||||
publish_para->callback(MQTT_PUBLISH_SUCCESS);
|
||||
}
|
||||
}
|
||||
if (publish_para->publish->topic != NULL)
|
||||
{
|
||||
free(publish_para->publish->topic);
|
||||
}
|
||||
|
||||
if (publish_para->publish->message.payload != NULL)
|
||||
{
|
||||
free(publish_para->publish->message.payload);
|
||||
}
|
||||
|
||||
if (publish_para->publish != NULL)
|
||||
{
|
||||
free(publish_para->publish);
|
||||
}
|
||||
|
||||
if (publish_para != NULL)
|
||||
{
|
||||
free(publish_para);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "luat_debug.h"
|
||||
#include "luat_rtos.h"
|
||||
#include "MQTTClient.h"
|
||||
#include "mqtt_publish.h"
|
||||
luat_rtos_task_handle mqtt_send_task_handle;
|
||||
|
||||
extern luat_rtos_task_handle mqtt_publish_task_handle;
|
||||
|
||||
void publish_callback(int result)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("mqtt_send_task send mqtt message result %d", result);
|
||||
}
|
||||
|
||||
static void mqtt_send_task(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
mqtt_publish_para_t *publish_para = NULL;
|
||||
publish_para = (mqtt_publish_para_t *)malloc(sizeof(mqtt_publish_para_t));
|
||||
memset(publish_para, 0x00, sizeof(mqtt_publish_para_t));
|
||||
|
||||
publish_para->publish = (mqttSendMsg *)malloc(sizeof(mqttSendMsg));
|
||||
memset(publish_para->publish, 0x00, sizeof(mqttSendMsg));
|
||||
|
||||
char topic[] = "/cloud_speaker/publish/test_topic";
|
||||
publish_para->publish->topic = malloc(sizeof(topic));
|
||||
memcpy(publish_para->publish->topic, topic, sizeof(topic));
|
||||
publish_para->publish->topicLen = sizeof(topic);
|
||||
|
||||
char payload[] = "{\"time\": \"2000-00-00\"}";
|
||||
publish_para->publish->message.payload = malloc(sizeof(payload));
|
||||
memcpy(publish_para->publish->message.payload, payload, sizeof(payload));
|
||||
|
||||
publish_para->publish->message.payloadlen = sizeof(payload) - 1;
|
||||
publish_para->publish->message.qos = 1;
|
||||
publish_para->callback = publish_callback;
|
||||
uint32_t id = 0;
|
||||
if (luat_rtos_message_send(mqtt_publish_task_handle, &id, (void *)publish_para) != 0)
|
||||
{
|
||||
LUAT_DEBUG_PRINT("colud_speaker_mqtt publish message send error");
|
||||
free(publish_para->publish->topic);
|
||||
free(publish_para->publish->message.payload);
|
||||
free(publish_para->publish);
|
||||
free(publish_para);
|
||||
|
||||
}
|
||||
luat_rtos_task_sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
void mqtt_send_task_init(void)
|
||||
{
|
||||
luat_rtos_task_create(&mqtt_send_task_handle, 2048, 20, "mqtt_send_task", mqtt_send_task, NULL, 0);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
#include "luat_uart.h"
|
||||
#include "luat_debug.h"
|
||||
|
||||
void luat_uart_recv_cb(int uart_id, uint32_t data_len){
|
||||
char* data_buff = malloc(data_len+1);
|
||||
memset(data_buff,0,data_len+1);
|
||||
luat_uart_read(uart_id, data_buff, data_len);
|
||||
LUAT_DEBUG_PRINT("luat_uart_cb uart_id:%d data:%s data_len:%d",uart_id,data_buff,data_len);
|
||||
if (strcmp("AT+CLIENTID?\r\n", data_buff) == 0)
|
||||
{
|
||||
char clientId[32] = {0};
|
||||
int ret = luat_kv_get("clientId", clientId, 16);
|
||||
if(ret > 0 )
|
||||
{
|
||||
luat_uart_write(LUAT_VUART_ID_0, clientId, strlen(clientId));
|
||||
}
|
||||
else
|
||||
{
|
||||
luat_uart_write(LUAT_VUART_ID_0, "OK", strlen("OK"));
|
||||
}
|
||||
}
|
||||
else if (strstr(data_buff, "AT+CLIENTID=") != NULL)
|
||||
{
|
||||
char *flag = NULL;
|
||||
flag = strstr(data_buff, "=");
|
||||
if(flag != NULL)
|
||||
{
|
||||
flag++;
|
||||
char *flag2 = NULL;
|
||||
flag2 = strstr(flag, "\r\n");
|
||||
if (flag2 != NULL)
|
||||
{
|
||||
int ret = luat_kv_set("clientId", flag, strlen(flag) - 2); //减去末尾的\r\n
|
||||
luat_uart_write(LUAT_VUART_ID_0, "OK", strlen("OK"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (strcmp("AT+USERNAME?\r\n", data_buff) == 0)
|
||||
{
|
||||
int ret = 0;
|
||||
char name[32] = {0};
|
||||
ret = luat_kv_get("username", name, 31);
|
||||
if (ret > 0)
|
||||
{
|
||||
luat_uart_write(LUAT_VUART_ID_0, name, strlen(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
luat_uart_write(LUAT_VUART_ID_0, "OK", strlen("OK"));
|
||||
}
|
||||
}
|
||||
else if (strstr(data_buff, "AT+USERNAME=") != NULL)
|
||||
{
|
||||
char *flag = NULL;
|
||||
flag = strstr(data_buff, "=");
|
||||
if(flag != NULL)
|
||||
{
|
||||
flag++;
|
||||
char *flag2 = NULL;
|
||||
flag2 = strstr(flag, "\r\n");
|
||||
if (flag2 != NULL)
|
||||
{
|
||||
int ret = luat_kv_set("username", flag, strlen(flag) - 2); //减去末尾的\r\n
|
||||
luat_uart_write(LUAT_VUART_ID_0, "OK", strlen("OK"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (strcmp("AT+PASSWORD?\r\n", data_buff) == 0)
|
||||
{
|
||||
int ret = 0;
|
||||
char name[32] = {0};
|
||||
ret = luat_kv_get("password", name, 31);
|
||||
if (ret > 0)
|
||||
{
|
||||
luat_uart_write(LUAT_VUART_ID_0, name, strlen(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
luat_uart_write(LUAT_VUART_ID_0, "OK", strlen("OK"));
|
||||
}
|
||||
}
|
||||
else if (strstr(data_buff, "AT+PASSWORD=") != NULL)
|
||||
{
|
||||
char *flag = NULL;
|
||||
flag = strstr(data_buff, "=");
|
||||
if(flag != NULL)
|
||||
{
|
||||
flag++;
|
||||
char *flag2 = NULL;
|
||||
flag2 = strstr(flag, "\r\n");
|
||||
if (flag2 != NULL)
|
||||
{
|
||||
int ret = luat_kv_set("password", flag, strlen(flag) - 2); //减去末尾的\r\n
|
||||
luat_uart_write(LUAT_VUART_ID_0, "OK", strlen("OK"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
free(data_buff);
|
||||
}
|
||||
|
||||
void usb_uart_init(void)
|
||||
{
|
||||
char send_buff[] = "hello LUAT!!!\n";
|
||||
luat_uart_t uart = {
|
||||
.id = LUAT_VUART_ID_0,
|
||||
};
|
||||
luat_uart_setup(&uart);
|
||||
luat_uart_ctrl(LUAT_VUART_ID_0, LUAT_UART_SET_RECV_CALLBACK, luat_uart_recv_cb);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
local TARGET_NAME = "cloud_speaker"
|
||||
local LIB_DIR = "$(buildir)/".. TARGET_NAME .. "/"
|
||||
local LIB_NAME = "lib" .. TARGET_NAME .. ".a "
|
||||
includes(SDK_TOP .. "/thirdparty/audio_decoder")
|
||||
target(TARGET_NAME)
|
||||
local LIB_DIR = "$(buildir)/mqttclient/"
|
||||
set_kind("static")
|
||||
set_targetdir(LIB_DIR)
|
||||
add_deps("audio_decoder")
|
||||
add_defines("MQTT_TASK",{public = true})
|
||||
|
||||
includes(SDK_TOP .. "/thirdparty/mqtt")
|
||||
add_deps("mqtt")
|
||||
includes(SDK_TOP .. "/thirdparty/cJSON")
|
||||
-- --加入代码和头文件
|
||||
add_includedirs(SDK_TOP .. "/thirdparty/mqtt/MQTTClient-C/src",{public = true})
|
||||
add_files(SDK_TOP .. "/thirdparty/mqtt/MQTTClient-C/src/*.c",{public = true})
|
||||
add_includedirs(SDK_TOP .. "/PLAT/core/tts/include/16k_lite_ver",{public = true})
|
||||
--加入自己代码和头文件
|
||||
add_includedirs("./inc",{public = true})
|
||||
add_files("./src/*.c",{public = true})
|
||||
|
||||
--可以继续增加add_includedirs和add_files
|
||||
-- add_includedirs("../../thirdparty/fal/inc",{public = true})
|
||||
-- add_includedirs("../../thirdparty/flashdb/inc",{public = true})
|
||||
-- add_includedirs("../../thirdparty/am_kv/inc",{public = true})
|
||||
-- add_files("../../thirdparty/fal/src/*.c",{public = true})
|
||||
-- add_files("../../thirdparty/flashdb/src/*.c",{public = true})
|
||||
-- add_files("../../thirdparty/am_kv/src/*.c",{public = true})
|
||||
--自动链接
|
||||
LIB_USER = LIB_USER .. SDK_TOP .. LIB_DIR .. LIB_NAME .. " "
|
||||
LIB_USER = LIB_USER .. SDK_TOP .. "/PLAT/core/lib/libaisound50_16K.a "
|
||||
--甚至可以加入自己的库
|
||||
target_end()
|
||||
Reference in New Issue
Block a user