### Example Project Directory Structure with Skills Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Illustrates the expected project directory structure after configuring custom skills for Cursor IDE. ```text your-project/ ├── .cursor/ │ └── skills/ │ ├── RTOS/ # RTOS Map SDK Skill │ │ ├── SKILL.md │ │ ├── api/ │ │ └── references/ │ ├── android-llm-agent/ # Android LLM Agent Skill │ │ ├── SKILL.md │ │ ├── api/ │ │ └── references/ │ └── ios-llm-agent-sdk/ # iOS LLM Agent Skill │ ├── SKILL.md │ ├── api/ │ └── references/ ├── src/ └── ... ``` -------------------------------- ### Link SDK IPC Communication Query Example Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/README.md Example natural language query for setting up IPC communication using the Link SDK. Use this in AI Chat to test Link SDK setup, including authorization and connection management. ```text Help me set up IPC communication with AMap APP using the Link SDK, including authorization and connection management ``` -------------------------------- ### Error Handling Example Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/error-codes.md Demonstrates how to handle initialization errors using a switch statement. ```c int32_t result = awk_init(&context); switch (result) { case 0: printf("初始化成功\n"); break; case -1: printf("错误:已初始化,不能重复初始化\n"); break; case -100: printf("错误:context 为空\n"); break; case -101: printf("错误:key 为空\n"); break; default: if (result <= -200 && result > -300) { printf("错误:render_adapter 不完整\n"); } else if (result <= -300 && result > -400) { printf("错误:file_adapter 不完整\n"); } break; } ``` -------------------------------- ### Full Navigation Example Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/navigation.md Demonstrates the typical sequence of operations for initializing navigation, setting callbacks, initializing the view, receiving data, and finally cleaning up resources. ```c // 1. 初始化导航 awk_navi_config_t config = {0}; awk_init_navi(&config); // 2. 设置回调 awk_navi_data_callback_t data_cb = { .update_navi_info = on_navi_info_update, .update_navi_location = on_location_update, .update_turn_info = on_turn_info_update }; awk_navi_add_data_callback(&data_cb); // 3. 初始化导航视图 awk_navi_view_config_t view_config = {0}; awk_init_navi_view(map_id, &view_config); // 4. 接收导航数据 awk_navi_data(pb_data, pb_len); // 5. 清理 awk_uninit_navi_view(); awk_uninit_navi(); ``` -------------------------------- ### Initialize SDK with Context and Error Handling Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/adapter-requirements.md Example of initializing the SDK in C, setting up the context with essential parameters and adapter functions, and handling potential initialization errors using a switch statement. ```c awk_context_t context = {0}; // 设置基本参数 context.key = "your_amap_key"; context.device_id = "your_device_id"; context.root_dir = "/path/to/sdk/data"; // 设置所有必需的适配器函数 context.render_adapter.begin_drawing = my_begin_drawing; context.render_adapter.commit_drawing = my_commit_drawing; // ... 设置其他所有必需函数 // 初始化 int32_t ret = awk_init(&context); if (ret != 0) { // 根据错误码定位问题 switch (ret) { case -100: printf("错误:上下文对象为空\n"); break; case -101: printf("错误:未设置高德开放平台 key\n"); break; case -200: printf("错误:未实现 render_adapter.begin_drawing\n"); break; // ... 处理其他错误码 default: printf("初始化失败,错误码:%d\n", ret); } } ``` -------------------------------- ### Agent SDK Integration Query Example Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/README.md Example natural language query for integrating the Agent SDK to enable map query functionality. Use this in AI Chat to test Agent SDK integration. ```text Help me integrate MALLMKit SDK into my iOS app and implement a natural language map query ``` -------------------------------- ### Initialize Log View and Action Buttons Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/integrate-agent.md Sets up a UITextView for displaying logs and creates floating action buttons for navigation and interaction. This is typically used during the initial setup of the agent's UI. ```Objective-C self.logTextView = [[UITextView alloc] initWithFrame:CGRectMake(8, 24, self.view.width - 16, logPanelHeight - 28)]; self.logTextView.backgroundColor = [UIColor clearColor]; self.logTextView.textColor = [UIColor greenColor]; self.logTextView.font = [UIFont fontWithName:@"Menlo" size:11]; self.logTextView.editable = NO; self.logTextView.scrollEnabled = YES; self.logTextView.showsVerticalScrollIndicator = YES; self.logTextView.textContainer.lineBreakMode = NSLineBreakByWordWrapping; self.logTextView.textContainer.maximumNumberOfLines = 0; self.logTextView.textContainerInset = UIEdgeInsetsMake(4, 0, 4, 0); self.logTextView.text = @"等待 Agent 回调...\n"; [self.logContainerView addSubview:self.logTextView]; // 4. 浮动操作按钮(日志面板上方:去第一个、是的、停止导航) CGFloat floatingY = self.logContainerView.top - AGENT_BTN_H - 12; CGFloat floatingX = self.view.width - AGENT_BTN_M; self.mStopNaviButton = [self createOutlineButton:@"⏹ 停止导航" action:@selector(testStopNavi) color:[UIColor systemRedColor]]; [self.mStopNaviButton sizeToFit]; self.mStopNaviButton.frame = CGRectMake(floatingX - self.mStopNaviButton.width, floatingY, self.mStopNaviButton.width, AGENT_BTN_H); [self.view addSubview:self.mStopNaviButton]; floatingX = self.mStopNaviButton.left - AGENT_BTN_M; self.mYesActionButton = [self createOutlineButton:@"✅ 是的" action:@selector(testSelectYes) color:[UIColor systemGreenColor]]; [self.mYesActionButton sizeToFit]; self.mYesActionButton.frame = CGRectMake(floatingX - self.mYesActionButton.width, floatingY, self.mYesActionButton.width, AGENT_BTN_H); [self.view addSubview:self.mYesActionButton]; floatingX = self.mYesActionButton.left - AGENT_BTN_M; self.mNextActionButton = [self createOutlineButton:@"👉 去第一个" action:@selector(testSelectFirst) color:[UIColor systemPurpleColor]]; [self.mNextActionButton sizeToFit]; self.mNextActionButton.frame = CGRectMake(floatingX - self.mNextActionButton.width, floatingY, self.mNextActionButton.width, AGENT_BTN_H); [self.view addSubview:self.mNextActionButton]; // 5. 初始化定位 [self initLocation]; ``` -------------------------------- ### Start Authentication Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/authorization.md Initiates the authorization process by launching the Gaode Maps app. The SDK handles the redirection and provides a callback with the authorization result. ```APIDOC ## Start Authentication ### Description Initiates the authorization process by launching the Gaode Maps app. The SDK handles the redirection and provides a callback with the authorization result. ### Method Signature ```objc - (void)startAuthenticationWithCallback:(void (^)(BOOL success, NSError * _Nonnull error))callback; ``` ### Parameters #### Callback Parameters - **success** (BOOL) - Indicates whether the authorization was successful. - **error** (NSError) - Contains error information if the authorization failed. ``` -------------------------------- ### Example Usage of Switching Navigation Modes Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/android-llm-agent/api/transport-mode.md Demonstrates how to call the `switchTransportType` method with different `TransportType` constants to change the navigation mode. ```java switchTransportType(TransportType.Drive); // 驾车 switchTransportType(TransportType.Ride); // 骑行 switchTransportType(TransportType.Walk); // 步行 switchTransportType(TransportType.EleBike); // 电动车 ``` -------------------------------- ### System Adapter Functions Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/adapter-requirements.md Provides functions for system-level operations like getting time and logging. ```APIDOC ## System Adapter (system_adapter) ### Required Functions | Function | Error Code | Description | |-----------------|------------|------------------------------| | `get_system_time` | -500 | Get system time (milliseconds) | | `log_printf` | -501 | Log output | ### Function Signature ```c typedef struct _awk_system_adapter_t { uint64_t (*get_system_time)(void); int (*log_printf)(const char* __fmt, ...); } awk_system_adapter_t; ``` ``` -------------------------------- ### App Authorization Flow Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/link-client.md Initiate the authorization process with the Gaode map app. This involves checking if the app is installed, redirecting to the App Store if not, and starting the authentication flow. Handle the callback to determine success or failure. ```Objective-C // 1. 检查高德 APP 是否安装 if (![[AMapAuthorizationManager sharedInstance] isInstallAMapApp]) { [[AMapAuthorizationManager sharedInstance] turnToAppStore]; return; } // 2. 发起授权 [[AMapAuthorizationManager sharedInstance] startAuthenticationWithCallback:^(BOOL success, NSError *error) { if (success) { NSLog(@"授权成功"); } }]; ``` -------------------------------- ### Test Query for RTOS Skill Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Example query to test the RTOS skill configuration in Cursor AI Chat. This helps verify if the AI can access and utilize the RTOS skill files. ```text Help me initialize the WatchSDK and create a map view on an RTOS device ``` -------------------------------- ### Test Query for Android LLM Agent Skill Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Example query to test the Android LLM Agent skill configuration. This verifies if the AI can correctly interpret and use the Android LLM Agent SDK. ```text Help me integrate the AMap LLM Agent SDK and send a natural language navigation query ``` -------------------------------- ### Test Query for iOS LLM Agent Skill Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Example query to test the iOS LLM Agent skill configuration. This ensures the AI can access and leverage the iOS LLM Agent SDK for natural language queries. ```text Help me integrate the LLM Agent SDK and send a natural language navigation query ``` -------------------------------- ### Get Simplified Route Information Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/navi-control.md Retrieves the simplified route PB data from the current highlighted route, starting from the vehicle's current position. ```APIDOC ## Get Simplified Route Information ### Description Retrieves the simplified route PB data from the current highlighted route, starting from the vehicle's current position. ### Method Objective-C ### Endpoint [[AMapNaviClientManager shareInstance] getPartialRouteGroupWithLimitPointSize:limitPointSize]; ### Parameters #### Path Parameters - **limitPointSize** (integer) - Required - Limits the number of coordinate points. ### Request Example ```objc // limitPointSize: 限制坐标点数量 AMapNaviPbData *partialRoute = [[AMapNaviClientManager shareInstance] getPartialRouteGroupWithLimitPointSize:100]; ``` ### Response - **partialRoute** (AMapNaviPbData) - The simplified route data. ``` -------------------------------- ### Get Simplified Route Information Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/navi-control.md Retrieves the simplified PB data for the current highlighted route, starting from the vehicle's current position. The limitPointSize parameter can be used to restrict the number of coordinate points. ```Objective-C // limitPointSize: 限制坐标点数量 AMapNaviPbData *partialRoute = [[AMapNaviClientManager shareInstance] getPartialRouteGroupWithLimitPointSize:100]; ``` -------------------------------- ### Initialize SDK Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/lifecycle.md Initializes the SDK with the provided context. Ensure all required adapter function pointers are valid. Returns 0 on success, or an error code if initialization fails or is already done. ```c int32_t awk_init(awk_context_t *context); ``` -------------------------------- ### Configure Agent Client and Callbacks Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/integrate-agent.md Sets up the agent client with direct SDK connection, logs, and query result callbacks. Handles POI and route search results, and initiates navigation simulation. ```objectivec - (void)initAgent { // 设置链路模式为 SDK 直连 [AMapAgentClientManager shareInstance].commandDestination = AMapAgentCommandDestinationSDK; // 设置日志监听 [[AMapAgentLog shareInstance] setLogDelegate:self]; // 设置查询结果回调 __weak typeof(self) weakSelf = self; [[AMapAgentClientManager shareInstance] setQueryResultCallback:^(AMapAgentQueryResult * _Nonnull queryResult) { __strong typeof(weakSelf) strongSelf = weakSelf; NSString *logMsg = [NSString stringWithFormat:@"summary: %@, actionType: %ld, stateType: %ld, seq: %ld", queryResult.summary, (long)queryResult.actionType, (long)queryResult.stateType, (long)queryResult.sequence]; NSLog(@"onQueryResult %@, sessionID: %@", logMsg, queryResult.sessionId); [strongSelf appendLogMessage:logMsg]; if (queryResult.resultObj) { if (queryResult.actionType == AMapAgentQueryResultActionTypeSearchPoi) { // POI 搜索结果 strongSelf.currentPoiResult = queryResult.resultObj; } else if (queryResult.actionType == AMapAgentQueryResultActionTypeRouteSearch) { // 顺路搜结果 strongSelf.routePois = queryResult.resultObj; } else if (queryResult.actionType == AMapAgentQueryResultActionTypeRequestRoute) { // 路线规划完成,自动开始驾车模拟导航 [[AMapNaviDriveManager sharedInstance] setIsUseInternalTTS:YES]; [[AMapNaviDriveManager sharedInstance] selectNaviRouteWithRouteID:0]; [[AMapNaviDriveManager sharedInstance] setEmulatorNaviSpeed:120]; [[AMapNaviDriveManager sharedInstance] startEmulatorNavi]; } } strongSelf.lastQueryResult = queryResult; }]; // 重置场景到主图 [[AMapAgentClientManager shareInstance] resetAgentScene:@"home"]; } ``` -------------------------------- ### Initialize Navigation Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/navigation.md Initializes the navigation system. Requires a configuration struct. ```c int32_t awk_init_navi(awk_navi_config_t *config); ``` -------------------------------- ### Get Map ID Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/navigation.md Retrieves the current map ID being used for navigation. ```c int32_t awk_navi_get_map_id(void); ``` -------------------------------- ### MapScene and GDMapView Creation Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/ios-demo-guide.md Demonstrates how to create a basic map scene and initialize a GDMapView. ```APIDOC ## Create Basic Map ### Description This section shows how to create a map scene with a specified mode and tile style, and then initialize a `GDMapView` with that scene. ### Usage ```swift // Create map scene let scene = MapScene( mode: .location(mapCenter: CLLocationCoordinate2D(latitude: 39.9, longitude: 116.4)), tileStyle: GDTileStyleGridAndPoi ) // Create map view let mapView = GDMapView(scene) ``` ``` -------------------------------- ### Initiate Authentication with Callback Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/authorization.md Use startAuthenticationWithCallback to launch the Gaode Maps app for authentication. The callback provides the success status and any error information. ```objectivec - (void)openAmap { __weak typeof(self) weakSelf = self; [[AMapAuthorizationManager sharedInstance] startAuthenticationWithCallback:^(BOOL success, NSError * _Nonnull error) { NSLog(@"授权结果: %d, error: %@", success, error); }]; } ``` -------------------------------- ### Server Probing Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/link-client.md Control and check the status of server probing to ensure the Gaode APP is responsive. This can be started and stopped manually. ```APIDOC ## Server Probing ### Description Control and check the status of server probing to ensure the Gaode APP is responsive. This can be started and stopped manually. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Method Calls ```objc // Start server probing [[AMapLinkManager sharedInstance] startServerProbing]; // Stop server probing [[AMapLinkManager sharedInstance] stopServerProbing]; // Check if server probing is currently active BOOL isProbing = [[AMapLinkManager sharedInstance] isServerProbing]; ``` ``` -------------------------------- ### Initialization and Uninitialization Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/lifecycle.md Functions for initializing the SDK context and uninitializing the SDK. ```APIDOC ## awk_init ### Description Initializes the SDK context with the provided parameters. ### Signature ```c int32_t awk_init(awk_context_t *context); ``` ### Parameters #### `awk_context_t` Parameters - **`device_id`** (char*) - Required - Unique device identifier. - **`key`** (char*) - Required - High German Open Platform Smart Hardware key. - **`root_dir`** (char*) - Required - SDK internal folder root path. - **`tile_mem_cache_max_size`** (uint32_t) - Optional - Tile memory cache size in KB. - **`tile_disk_cache_max_size`** (uint32_t) - Optional - Tile disk cache size in MB. - **`tile_load_mode`** (int32_t) - Optional - Load mode: offline, online, or hybrid. - **`tile_pixel_mode`** (awk_pixel_mode_t) - Optional - Pixel format. - **`memory_adapter`** (awk_memory_adapter_t) - Required - Memory adapter. - **`file_adapter`** (awk_file_adapter_t) - Required - File adapter. - **`network_adapter`** (awk_network_adapter_t) - Required - Network adapter. - **`render_adapter`** (awk_render_adapter_t) - Required - Render adapter. - **`system_adapter`** (awk_system_adapter_t) - Required - System adapter. ### Return Value - **0**: Success. - **-1**: Already initialized, cannot re-initialize. - **-100**: `context` is null. - **-101**: `key` is null. - **-102**: `device_id` is null. - **-103**: `root_dir` is null. - **-2xx**: `render_adapter` function pointer is null. - **-3xx**: `file_adapter` function pointer is null. - **-4xx**: `memory_adapter` function pointer is null. - **-5xx**: `system_adapter` function pointer is null. - **-6xx**: `network_adapter` function pointer is null. ## awk_uninit ### Description Uninitializes the SDK. ### Signature ```c int32_t awk_uninit(void); ``` ### Return Value - **0**: Success. - **-1**: Not initialized. - **-3**: Calling thread differs from initialization thread. ``` -------------------------------- ### Create Basic Map Scene and View Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/ios-demo-guide.md Initializes a map scene with a specified mode and tile style, then creates a map view using the scene. ```swift // 创建地图场景 let scene = MapScene( mode: .location(mapCenter: CLLocationCoordinate2D(latitude: 39.9, longitude: 116.4)), tileStyle: GDTileStyleGridAndPoi ) // 创建地图视图 let mapView = GDMapView(scene) ``` -------------------------------- ### Configure Navigation Environment Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/integrate-agent.md Sets up the navigation environment, including home and work locations, vehicle information, and navigation type. Also adds a listener for navigation data. ```objectivec - (void)initNavi { AMapNaviEnv *env = [AMapNaviEnv new]; AMapAgentPOI *homeLocation = [AMapAgentPOI new]; env.homeLocation = homeLocation; AMapAgentPOI *workLocation = [AMapAgentPOI new]; env.workLocation = workLocation; env.homeLocation.name = @"望京西园一区"; env.homeLocation.coordinate = CLLocationCoordinate2DMake(40.004585, 116.476334); env.homeLocation.uid = @"B000A7QPDF"; env.workLocation.name = @"阿里中心·望京B座"; env.workLocation.coordinate = CLLocationCoordinate2DMake(40.002577, 116.489854); env.workLocation.uid = @"B0FFHU7UFS"; AMapNaviVehicleInfo *carInfo = [AMapNaviVehicleInfo new]; env.amapVehicleInfo = carInfo; env.amapVehicleInfo.vehicleId = @"京DFZ588"; env.amapNaviType = AMapNaviTypeDrive; env.multipleRoute = YES; env.avoidCongestion = NO; env.avoidHighway = NO; env.avoidCost = NO; env.prioritiseHighway = NO; [AMapNaviClientManager shareInstance].amapNaviEnv = env; [AMapNaviClientManager shareInstance].locationUpdateInterval = 1.0; // 导航数据监听 self.naviDataCallback = ^(AMapNaviPbData * _Nonnull navidata) { }; [[AMapNaviClientManager shareInstance] addNaviDataListener:self.naviDataCallback]; } ``` -------------------------------- ### System Adapter Function Signatures Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/adapter-requirements.md Defines the structure for system interaction functions: getting system time and logging. These are crucial for time-based operations and debugging. ```c typedef struct _awk_system_adapter_t { uint64_t (*get_system_time)(void); int (*log_printf)(const char* __fmt, ...); } awk_system_adapter_t; ``` -------------------------------- ### Server Probing Control Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/link-client.md Manually start or stop server probing to check the server's responsiveness. You can also query the current probing status. ```Objective-C [[AMapLinkManager sharedInstance] startServerProbing]; // 手动开始探测 [[AMapLinkManager sharedInstance] stopServerProbing]; // 停止探测 BOOL isProbing = [[AMapLinkManager sharedInstance] isServerProbing]; ``` -------------------------------- ### SDK Initialization Check Flow Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/adapter-requirements.md This C code snippet demonstrates the internal checks performed during SDK initialization, including checking for prior initialization, validating context and adapters, and proceeding with the initialization process. ```c int32_t awk_init(awk_context_t *context) { // 1. 检查是否已初始化 if (s_inited) { return -1; } // 2. 检查上下文和适配器 int32_t re = awk_check_context(context); if (re != 0) { return re; // 返回具体的错误码 } // 3. 继续初始化流程 // ... } ``` -------------------------------- ### Get Navigation Structured Data (cmd: 5) Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/data-transfer.md Command to retrieve structured data related to the current navigation. This command does not require any additional data parameters. ```APIDOC ## Get Navigation Structured Data (cmd: 5) Command to retrieve structured data related to the current navigation. This command does not require any additional data parameters. ### Command Structure ```json { "cmd": 5, "requestId": NSNumber } ``` ### Example ```objc NSDictionary *command = @{ @"cmd": @(5), @"requestId": @2222225 }; [self sendData:command]; ``` ``` -------------------------------- ### Link Specific Skills using Symbolic Links (Windows) Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Create symbolic links for specific skill directories on Windows. Ensure you run the Command Prompt as an administrator. ```bash # Windows (Run CMD as Administrator) mklink /D .cursor\skills\RTOS C:\path\to\open_sdk_skills\RTOS mklink /D .cursor\skills\android-llm-agent C:\path\to\open_sdk_skills\android-llm-agent mklink /D .cursor\skills\ios-llm-agent-sdk C:\path\to\open_sdk_skills\ios-llm-agent-sdk ``` -------------------------------- ### Initialization Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/navigation.md Initializes the navigation system and its associated view. It requires a configuration structure for navigation and a view configuration for the map display. Proper cleanup is essential using uninitialization functions. ```APIDOC ## Initialize Navigation ### Description Initializes the navigation system. ### Signature ```c int32_t awk_init_navi(awk_navi_config_t *config); ``` ### Parameters * **config** (awk_navi_config_t *) - Pointer to the navigation configuration structure. ## Initialize Navigation View ### Description Initializes the navigation view on a given map. ### Signature ```c int32_t awk_init_navi_view(uint32_t map_id, awk_navi_view_config_t *view_config); ``` ### Parameters * **map_id** (uint32_t) - The ID of the map to initialize the view on. * **view_config** (awk_navi_view_config_t *) - Pointer to the navigation view configuration structure. ### Notes External map operations (rotation, zoom, etc.) are not allowed during navigation as they may conflict with internal operations. ## Uninitialize Navigation ### Description Uninitializes the navigation system. ### Signature ```c int32_t awk_uninit_navi(void); ``` ## Uninitialize Navigation View ### Description Uninitializes the navigation view. ### Signature ```c int32_t awk_uninit_navi_view(void); ``` ``` -------------------------------- ### Get Navigation Structured Data Command (cmd: 5) Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/data-transfer.md Send a JSON command to request structured navigation data. This command does not require a 'data' field. ```Objective-C NSDictionary *command = @{ @"cmd": @(5), @"requestId": @2222225 }; [self sendData:command]; ``` -------------------------------- ### Clone amap-sdk-skills Repository Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Use this command to clone the SDK repository locally. This is the recommended method for obtaining the skill files. ```bash # Clone the repository locally git clone # Enter the directory cd open_sdk_skills ``` -------------------------------- ### AMap LLM Agent Directory Structure Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/android-llm-agent/README.md Overview of the directory structure for the android-llm-agent project, detailing the location of skill files, API guides, and reference documentation. ```text android-llm-agent/ ├── SKILL.md # Main skill file (AI entry point) ├── api/ # API guides │ ├── quick-start.md # Quick integration guide │ ├── agent-query.md # Send AI queries │ ├── query-result.md # Handle query results │ ├── link-client.md # LinkClient communication │ ├── transport-mode.md # Transport mode switching │ ├── logger.md # Logger configuration │ └── lifecycle.md # Lifecycle management └── references/ # Reference documentation ├── core-classes.md # Core classes reference ├── troubleshooting.md # Troubleshooting guide └── voice-commands.md # Voice command examples ``` -------------------------------- ### AMapAuthorizationManager for App Authorization Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/link-client.md Manage the authorization process with the Gaode APP. This includes checking if the app is installed, initiating the authentication flow, and handling the callback URL. ```APIDOC ## App Authorization with AMapAuthorizationManager ### Description Manage the authorization process with the Gaode APP. This includes checking if the app is installed, initiating the authentication flow, and handling the callback URL. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Method Calls ```objc // 1. Check if the Gaode APP is installed if (![[AMapAuthorizationManager sharedInstance] isInstallAMapApp]) { // If not installed, redirect to the App Store [[AMapAuthorizationManager sharedInstance] turnToAppStore]; return; } // 2. Initiate the authorization process [[AMapAuthorizationManager sharedInstance] startAuthenticationWithCallback:^(BOOL success, NSError *error) { if (success) { NSLog(@"Authorization successful"); } else { NSLog(@"Authorization failed: %@", error.localizedDescription); } }]; // 3. Handle the callback URL in your AppDelegate // In your AppDelegate.m: // - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { // return [[AMapAuthorizationManager sharedInstance] handleURL:url]; // } ``` ### Parameters #### `startAuthenticationWithCallback` Block Parameters: - **success** (BOOL) - Indicates whether the authorization was successful. - **error** (NSError *) - An error object if the authorization failed. ``` -------------------------------- ### Initialize Agent and Navigation Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/integrate-agent.md Initializes the Agent and navigation environment within the init method. Ensure both are bound before viewDidLoad. ```objectivec - (instancetype)init { if (self = [super init]) { [self initAgent]; [self initNavi]; } return self; } ``` -------------------------------- ### Correct Network Send Implementation with SDK Types Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/SKILL.md Demonstrates the correct way to implement a network send function by first verifying SDK structure definitions in header files. This avoids assumptions about data types and field names. ```Objective-C // ❌ 错误做法:直接编写代码 static uint64_t aw_network_send(awk_http_request_t *request, ...) { // 假设 request->body 是 char* urlRequest.HTTPBody = [NSData dataWithBytes:request->body length:request->body_size]; } // ✅ 正确做法:先读取 awk_adapter.h 确认结构体定义 // 1. read_file("awk_adapter.h") 查看 awk_http_request_t 定义 // 2. 发现 body 是 awk_http_buffer_t* 类型 // 3. 再查看 awk_http_buffer_t 定义 // 4. 按照实际定义编写代码 static uint64_t aw_network_send(awk_http_request_t *request, ...) { // 正确:使用 request->body->buffer 和 request->body->length if (request->body && request->body->buffer && request->body->length > 0) { urlRequest.HTTPBody = [NSData dataWithBytes:request->body->buffer length:request->body->length]; } } ``` -------------------------------- ### Required Header Files for Rendering Adapter Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/SKILL.md Include these header files to define the rendering adapter interface and basic types. ```c #include "awk_adapter.h" // 渲染适配器接口定义 #include "awk_defines.h" // 基础类型定义 ``` -------------------------------- ### Set up LinkClient for Cross-App Navigation Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/android-llm-agent/README.md Set up the LinkClient to enable communication with the AMap APP for seamless cross-application navigation. ```text Set up LinkClient to communicate with the AMap APP for cross-app navigation ``` -------------------------------- ### Navigation Configuration Structure Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/navigation.md Defines the configuration parameters for navigation initialization, including car icon overlay. ```c typedef struct { awk_map_point_overlay_t car_overlay; // 车标覆盖物 // ... 其他配置 } awk_navi_config_t; ``` -------------------------------- ### Implement POSIX File Adapter Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/adapters.md Provides a POSIX-compliant implementation for file adapter functions. This includes wrappers for standard C file I/O operations and POSIX system calls for file and directory management. ```c static void* awk_file_open_adapter(const char *filename, const char *mode) { return (void*)fopen(filename, mode); } static int awk_file_close_adapter(void* handler) { return fclose((FILE*)handler); } static size_t awk_file_read_adapter(void *ptr, size_t size, void* handler) { return fread(ptr, size, 1, (FILE*)handler); } static size_t awk_file_write_adapter(void *ptr, size_t size, void* handler) { return fwrite(ptr, size, 1, (FILE*)handler); } static int awk_file_seek_adapter(void *handler, long offset, int where) { return fseek((FILE*)handler, offset, where); } static bool awk_file_exists_adapter(const char *path) { return access(path, 0) == 0; } static bool awk_file_dir_exists_adapter(const char *path) { struct stat st; return (stat(path, &st) == 0) && S_ISDIR(st.st_mode); } static int awk_file_mkdir_adapter(const char *path, uint16_t mode) { return mkdir(path, mode); } static void awk_file_readdir_adapter(void *dir, awk_file_dir_foreach foreach, void *user_data) { struct dirent *entry; while ((entry = readdir((DIR*)dir)) != NULL) { awk_file_dir_entry dir_entry = {.file_name = entry->d_name}; foreach(dir_entry, user_data); } } ``` -------------------------------- ### Implementation File Declarations for Agent Demo ViewController Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/integrate-agent.md Define constants and declare private properties and protocols for the AMapAgentDemoViewController implementation file, including location manager, callbacks, and UI elements. ```objc static const CGFloat AGENT_BTN_H = 30; static const CGFloat AGENT_BTN_M = 6; static const CGFloat AGENT_BTN_PADDING_H = 12; static const CGFloat AGENT_BTN_PADDING_V = 4; static const CGFloat AGENT_BTN_RADIUS = 15; static const CGFloat AGENT_LOG_VIEW_H = 160; typedef void (^AgentNaviDataCallback)(AMapNaviPbData *navidata); @interface AMapAgentDemoViewController () @property (nonatomic, strong) CLLocationManager *locationManager; @property (nonatomic, copy) AgentNaviDataCallback naviDataCallback; @property (nonatomic, strong) AMapPOIResult *currentPoiResult; @property (nonatomic, copy) NSArray *routePois; @property (nonatomic, strong) AMapAgentQueryResult *lastQueryResult; @property (nonatomic, strong) UIButton *mStopNaviButton; @property (nonatomic, strong) UIButton *mNextActionButton; @property (nonatomic, strong) UIButton *mYesActionButton; @property (nonatomic, strong) UITextField *queryTextField; @property (nonatomic, strong) UIView *inputContainerView; @property (nonatomic, strong) UITextView *logTextView; @property (nonatomic, strong) UIView *logContainerView; @end ``` -------------------------------- ### Info.plist Scheme Configuration Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/link-client.md Configure the Info.plist file to include 'amapuri' in LSApplicationQueriesSchemes, which is necessary for the app link functionality. ```XML LSApplicationQueriesSchemes amapuri ``` -------------------------------- ### Check SDK Initialization Status Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/android-llm-agent/references/troubleshooting.md Verifies if the API Key is set and network permissions are granted before initializing the SDK. Ensure API Key is correct and network permissions are enabled. ```java private boolean checkInitialization() { // 检查 API Key if (TextUtils.isEmpty(getApiKey())) { Log.e(TAG, "API Key not set"); return false; } // 检查网络权限 if (!hasNetworkPermission()) { Log.e(TAG, "Network permission not granted"); return false; } return true; } ``` -------------------------------- ### Link Specific Skills using Symbolic Links (macOS/Linux) Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md Create symbolic links to specific skill directories within your project's .cursor/skills directory. This is recommended for easy updates. ```bash # macOS / Linux - Link the specific skill you need ln -s /path/to/open_sdk_skills/RTOS .cursor/skills/RTOS ln -s /path/to/open_sdk_skills/android-llm-agent .cursor/skills/android-llm-agent ln -s /path/to/open_sdk_skills/ios-llm-agent-sdk .cursor/skills/ios-llm-agent-sdk ``` -------------------------------- ### Link RTOS Skill to Project Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/README.md Link the RTOS skill to your project by creating a symbolic link. This step is crucial for the skill to be recognized by the project. ```bash # Link the RTOS skill to your project ln -s /path/to/open_sdk_skills/RTOS .cursor/skills/RTOS ``` -------------------------------- ### AMapLinkManager Initialization and Connection Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/link-client.md Configure and establish an IPC connection with the Gaode APP using `AMapLinkManager`. This includes setting up auto-reconnect behavior and initiating the connection. ```APIDOC ## AMapLinkManager Initialization and Connection ### Description Configure and establish an IPC connection with the Gaode APP using `AMapLinkManager`. This includes setting up auto-reconnect behavior and initiating the connection. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Parameters #### `AMapLinkConnectConfig` Parameters: - **autoReconnect** (BOOL) - Optional - Whether to automatically reconnect. Defaults to NO. - **maxReconnectAttempts** (NSInteger) - Optional - The maximum number of reconnection attempts. Defaults to 5. - **reconnectDelay** (double) - Optional - The delay in seconds between reconnection attempts. Defaults to 2.0. ### Method Calls ```objc // Initialize with default configuration AMapLinkConnectConfig *config = [AMapLinkConnectConfig defaultConfig]; // Customize configuration config.autoReconnect = YES; config.maxReconnectAttempts = 5; config.reconnectDelay = 2.0; // Initialize the shared instance with the configuration [[AMapLinkManager sharedInstance] initWithConnectConfig:config]; // Establish the connection [[AMapLinkManager sharedInstance] connect]; ``` ``` -------------------------------- ### iOS begin_drawing Implementation Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/SKILL.md Implements the `aw_begin_drawing` function for iOS. It initializes global dictionaries if not already done, saves the rendering context, and creates a UIKit graphics context. Note that the scale is fixed at 1.0. ```objc static void aw_begin_drawing(uint32_t map_id, awk_render_context_t context) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ g_renderContexts = [NSMutableDictionary dictionary]; g_renderedImages = [NSMutableDictionary dictionary]; }); // 保存渲染上下文 RenderContext renderCtx; renderCtx.width = context.width; renderCtx.height = context.height; NSValue *value = [NSValue valueWithBytes:&renderCtx objCType:@encode(RenderContext)]; g_renderContexts[@(map_id)] = value; // 创建图形上下文(scale 使用固定值 1.0) CGSize size = CGSizeMake(context.width, context.height); UIGraphicsBeginImageContextWithOptions(size, NO, 1.0); NSLog(@"[Render] Begin drawing for map %d, size: %dx%d", map_id, context.width, context.height); } ``` -------------------------------- ### 内存适配器实现 Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/ios-integration.md 实现了 WatchSDK 的内存管理适配器,使用 Foundation 的 malloc, free, calloc, realloc。 ```objc + (awk_memory_adapter_t)memoryAdapter { static awk_memory_adapter_t adapter = { .mem_malloc = aw_mem_malloc, .mem_free = aw_mem_free, .mem_calloc = aw_mem_calloc, .mem_realloc = aw_mem_realloc }; return adapter; } static void* aw_mem_malloc(size_t size) { return malloc(size); } static void aw_mem_free(void* ptr) { if (ptr) free(ptr); } static void* aw_mem_calloc(size_t count, size_t size) { return calloc(count, size); } static void* aw_mem_realloc(void* ptr, size_t size) { return realloc(ptr, size); } ``` -------------------------------- ### Initialize Navigation View Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/navigation.md Initializes the navigation view on a specific map. External map manipulation is not allowed during navigation to prevent conflicts. ```c int32_t awk_init_navi_view(uint32_t map_id, awk_navi_view_config_t *view_config); ``` -------------------------------- ### Tile File Adapter Function Signature Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/adapter-requirements.md Defines the callback function for loading tile files. This is conditionally required when specific map tile styles are used. ```c typedef struct _awk_map_tile_file_adapter_t { bool (*on_tile_file)(const char* tile_file_key, char *file_path, size_t *file_offset, size_t *file_size); } awk_map_tile_file_adapter_t; ``` -------------------------------- ### Uninitialize SDK Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/api/lifecycle.md Uninitializes the SDK. This function should be called from the same thread that called awk_init. Returns 0 on success, or an error code if not initialized or called from a different thread. ```c int32_t awk_uninit(void); ``` -------------------------------- ### Create Skills Directory in Cursor Project Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/README.md This command creates the necessary directory for custom skills within your Cursor project. Ensure you are in the project's root directory. ```bash mkdir -p .cursor/skills ``` -------------------------------- ### Tile File Adapter Functions Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/RTOS/references/adapter-requirements.md Provides a callback function for loading tile files, conditionally required based on map tile style. ```APIDOC ## Tile File Adapter (tile_file_adapter) ### Required Functions | Function | Error Code | Description | Required Condition | |--------------|------------|--------------------------|------------------------------------------------------------------------------------| | `on_tile_file` | -800 | Load tile file callback | **Conditionally Required** | **Conditional Requirement Explanation**: - This is a required function when `tile_style` is `AWK_MAP_TILE_STYLE_GRID_AND_POI` or `AWK_MAP_TILE_STYLE_ROAD_AND_POI`. ### Function Signature ```c typedef struct _awk_map_tile_file_adapter_t { bool (*on_tile_file)(const char* tile_file_key, char *file_path, size_t *file_offset, size_t *file_size); } awk_map_tile_file_adapter_t; ``` ``` -------------------------------- ### Import Core Headers for Agent SDK Source: https://github.com/amap-demo/amap-sdk-skills/blob/main/ios-llm-agent-sdk/api/integrate-agent.md Import the necessary headers for using the Agent SDK and related functionalities like navigation and location services. ```objc #import #import #import "AMapAgentDemoViewController.h" #import #import #import #import #import #import #import #import #import #import #import #import #import #import "UIView+Layout.h" ```